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: (128 commits)
USB: fix codingstyle issues in drivers/usb/core/*.c
USB: fix codingstyle issues in drivers/usb/core/message.c
USB: fix codingstyle issues in drivers/usb/core/hcd-pci.c
USB: fix codingstyle issues in drivers/usb/core/devio.c
USB: fix codingstyle issues in drivers/usb/core/devices.c
USB: fix codingstyle issues in drivers/usb/core/*.h
USB: fix codingstyle issues in include/linux/usb/
USB: fix codingstyle issues in include/linux/usb.h
USB: mark USB drivers as being GPL only
USB: use a real vendor and product id for root hubs
USB: mount options: fix usbfs
USB: Fix usb_serial_driver structure for Kobil cardreader driver.
usb: ehci should use u16 for isochronous intervals
usb: ehci, remove false clear-reset path
USB: Use menuconfig objects
usb: ohci-sm501 driver
usb: dma bounce buffer support
USB: last abuses of intfdata in close for usb-serial drivers
USB: kl5kusb105 don't flush to logically disconnected devices
USB: oti6858: cleanup
...

+8196 -2680
+33
Documentation/ABI/testing/sysfs-bus-usb
··· 52 52 facility is inherently dangerous, it is disabled by default 53 53 for all devices except hubs. For more information, see 54 54 Documentation/usb/persist.txt. 55 + 56 + What: /sys/bus/usb/device/.../power/connected_duration 57 + Date: January 2008 58 + KernelVersion: 2.6.25 59 + Contact: Sarah Sharp <sarah.a.sharp@intel.com> 60 + Description: 61 + If CONFIG_PM and CONFIG_USB_SUSPEND are enabled, then this file 62 + is present. When read, it returns the total time (in msec) 63 + that the USB device has been connected to the machine. This 64 + file is read-only. 65 + Users: 66 + PowerTOP <power@bughost.org> 67 + http://www.lesswatts.org/projects/powertop/ 68 + 69 + What: /sys/bus/usb/device/.../power/active_duration 70 + Date: January 2008 71 + KernelVersion: 2.6.25 72 + Contact: Sarah Sharp <sarah.a.sharp@intel.com> 73 + Description: 74 + If CONFIG_PM and CONFIG_USB_SUSPEND are enabled, then this file 75 + is present. When read, it returns the total time (in msec) 76 + that the USB device has been active, i.e. not in a suspended 77 + state. This file is read-only. 78 + 79 + Tools can use this file and the connected_duration file to 80 + compute the percentage of time that a device has been active. 81 + For example, 82 + echo $((100 * `cat active_duration` / `cat connected_duration`)) 83 + will give an integer percentage. Note that this does not 84 + account for counter wrap. 85 + Users: 86 + PowerTOP <power@bughost.org> 87 + http://www.lesswatts.org/projects/powertop/
-16
Documentation/feature-removal-schedule.txt
··· 156 156 157 157 --------------------------- 158 158 159 - What: USB driver API moves to EXPORT_SYMBOL_GPL 160 - When: February 2008 161 - Files: include/linux/usb.h, drivers/usb/core/driver.c 162 - Why: The USB subsystem has changed a lot over time, and it has been 163 - possible to create userspace USB drivers using usbfs/libusb/gadgetfs 164 - that operate as fast as the USB bus allows. Because of this, the USB 165 - subsystem will not be allowing closed source kernel drivers to 166 - register with it, after this grace period is over. If anyone needs 167 - any help in converting their closed source drivers over to use the 168 - userspace filesystems, please contact the 169 - linux-usb-devel@lists.sourceforge.net mailing list, and the developers 170 - there will be glad to help you out. 171 - Who: Greg Kroah-Hartman <gregkh@suse.de> 172 - 173 - --------------------------- 174 - 175 159 What: vm_ops.nopage 176 160 When: Soon, provided in-kernel callers have been converted 177 161 Why: This interface is replaced by vm_ops.fault, but it has been around
+510
Documentation/usb/gadget_printer.txt
··· 1 + 2 + Linux USB Printer Gadget Driver 3 + 06/04/2007 4 + 5 + Copyright (C) 2007 Craig W. Nadler <craig@nadler.us> 6 + 7 + 8 + 9 + GENERAL 10 + ======= 11 + 12 + This driver may be used if you are writing printer firmware using Linux as 13 + the embedded OS. This driver has nothing to do with using a printer with 14 + your Linux host system. 15 + 16 + You will need a USB device controller and a Linux driver for it that accepts 17 + a gadget / "device class" driver using the Linux USB Gadget API. After the 18 + USB device controller driver is loaded then load the printer gadget driver. 19 + This will present a printer interface to the USB Host that your USB Device 20 + port is connected to. 21 + 22 + This driver is structured for printer firmware that runs in user mode. The 23 + user mode printer firmware will read and write data from the kernel mode 24 + printer gadget driver using a device file. The printer returns a printer status 25 + byte when the USB HOST sends a device request to get the printer status. The 26 + user space firmware can read or write this status byte using a device file 27 + /dev/g_printer . Both blocking and non-blocking read/write calls are supported. 28 + 29 + 30 + 31 + 32 + HOWTO USE THIS DRIVER 33 + ===================== 34 + 35 + To load the USB device controller driver and the printer gadget driver. The 36 + following example uses the Netchip 2280 USB device controller driver: 37 + 38 + modprobe net2280 39 + modprobe g_printer 40 + 41 + 42 + The follow command line parameter can be used when loading the printer gadget 43 + (ex: modprobe g_printer idVendor=0x0525 idProduct=0xa4a8 ): 44 + 45 + idVendor - This is the Vendor ID used in the device descriptor. The default is 46 + the Netchip vendor id 0x0525. YOU MUST CHANGE TO YOUR OWN VENDOR ID 47 + BEFORE RELEASING A PRODUCT. If you plan to release a product and don't 48 + already have a Vendor ID please see www.usb.org for details on how to 49 + get one. 50 + 51 + idProduct - This is the Product ID used in the device descriptor. The default 52 + is 0xa4a8, you should change this to an ID that's not used by any of 53 + your other USB products if you have any. It would be a good idea to 54 + start numbering your products starting with say 0x0001. 55 + 56 + bcdDevice - This is the version number of your product. It would be a good idea 57 + to put your firmware version here. 58 + 59 + iManufacturer - A string containing the name of the Vendor. 60 + 61 + iProduct - A string containing the Product Name. 62 + 63 + iSerialNum - A string containing the Serial Number. This should be changed for 64 + each unit of your product. 65 + 66 + iPNPstring - The PNP ID string used for this printer. You will want to set 67 + either on the command line or hard code the PNP ID string used for 68 + your printer product. 69 + 70 + qlen - The number of 8k buffers to use per endpoint. The default is 10, you 71 + should tune this for your product. You may also want to tune the 72 + size of each buffer for your product. 73 + 74 + 75 + 76 + 77 + USING THE EXAMPLE CODE 78 + ====================== 79 + 80 + This example code talks to stdout, instead of a print engine. 81 + 82 + To compile the test code below: 83 + 84 + 1) save it to a file called prn_example.c 85 + 2) compile the code with the follow command: 86 + gcc prn_example.c -o prn_example 87 + 88 + 89 + 90 + To read printer data from the host to stdout: 91 + 92 + # prn_example -read_data 93 + 94 + 95 + To write printer data from a file (data_file) to the host: 96 + 97 + # cat data_file | prn_example -write_data 98 + 99 + 100 + To get the current printer status for the gadget driver: 101 + 102 + # prn_example -get_status 103 + 104 + Printer status is: 105 + Printer is NOT Selected 106 + Paper is Out 107 + Printer OK 108 + 109 + 110 + To set printer to Selected/On-line: 111 + 112 + # prn_example -selected 113 + 114 + 115 + To set printer to Not Selected/Off-line: 116 + 117 + # prn_example -not_selected 118 + 119 + 120 + To set paper status to paper out: 121 + 122 + # prn_example -paper_out 123 + 124 + 125 + To set paper status to paper loaded: 126 + 127 + # prn_example -paper_loaded 128 + 129 + 130 + To set error status to printer OK: 131 + 132 + # prn_example -no_error 133 + 134 + 135 + To set error status to ERROR: 136 + 137 + # prn_example -error 138 + 139 + 140 + 141 + 142 + EXAMPLE CODE 143 + ============ 144 + 145 + 146 + #include <stdio.h> 147 + #include <stdlib.h> 148 + #include <fcntl.h> 149 + #include <linux/poll.h> 150 + #include <sys/ioctl.h> 151 + #include <linux/usb/g_printer.h> 152 + 153 + #define PRINTER_FILE "/dev/g_printer" 154 + #define BUF_SIZE 512 155 + 156 + 157 + /* 158 + * 'usage()' - Show program usage. 159 + */ 160 + 161 + static void 162 + usage(const char *option) /* I - Option string or NULL */ 163 + { 164 + if (option) { 165 + fprintf(stderr,"prn_example: Unknown option \"%s\"!\n", 166 + option); 167 + } 168 + 169 + fputs("\n", stderr); 170 + fputs("Usage: prn_example -[options]\n", stderr); 171 + fputs("Options:\n", stderr); 172 + fputs("\n", stderr); 173 + fputs("-get_status Get the current printer status.\n", stderr); 174 + fputs("-selected Set the selected status to selected.\n", stderr); 175 + fputs("-not_selected Set the selected status to NOT selected.\n", 176 + stderr); 177 + fputs("-error Set the error status to error.\n", stderr); 178 + fputs("-no_error Set the error status to NO error.\n", stderr); 179 + fputs("-paper_out Set the paper status to paper out.\n", stderr); 180 + fputs("-paper_loaded Set the paper status to paper loaded.\n", 181 + stderr); 182 + fputs("-read_data Read printer data from driver.\n", stderr); 183 + fputs("-write_data Write printer sata to driver.\n", stderr); 184 + fputs("-NB_read_data (Non-Blocking) Read printer data from driver.\n", 185 + stderr); 186 + fputs("\n\n", stderr); 187 + 188 + exit(1); 189 + } 190 + 191 + 192 + static int 193 + read_printer_data() 194 + { 195 + struct pollfd fd[1]; 196 + 197 + /* Open device file for printer gadget. */ 198 + fd[0].fd = open(PRINTER_FILE, O_RDWR); 199 + if (fd[0].fd < 0) { 200 + printf("Error %d opening %s\n", fd[0].fd, PRINTER_FILE); 201 + close(fd[0].fd); 202 + return(-1); 203 + } 204 + 205 + fd[0].events = POLLIN | POLLRDNORM; 206 + 207 + while (1) { 208 + static char buf[BUF_SIZE]; 209 + int bytes_read; 210 + int retval; 211 + 212 + /* Wait for up to 1 second for data. */ 213 + retval = poll(fd, 1, 1000); 214 + 215 + if (retval && (fd[0].revents & POLLRDNORM)) { 216 + 217 + /* Read data from printer gadget driver. */ 218 + bytes_read = read(fd[0].fd, buf, BUF_SIZE); 219 + 220 + if (bytes_read < 0) { 221 + printf("Error %d reading from %s\n", 222 + fd[0].fd, PRINTER_FILE); 223 + close(fd[0].fd); 224 + return(-1); 225 + } else if (bytes_read > 0) { 226 + /* Write data to standard OUTPUT (stdout). */ 227 + fwrite(buf, 1, bytes_read, stdout); 228 + fflush(stdout); 229 + } 230 + 231 + } 232 + 233 + } 234 + 235 + /* Close the device file. */ 236 + close(fd[0].fd); 237 + 238 + return 0; 239 + } 240 + 241 + 242 + static int 243 + write_printer_data() 244 + { 245 + struct pollfd fd[1]; 246 + 247 + /* Open device file for printer gadget. */ 248 + fd[0].fd = open (PRINTER_FILE, O_RDWR); 249 + if (fd[0].fd < 0) { 250 + printf("Error %d opening %s\n", fd[0].fd, PRINTER_FILE); 251 + close(fd[0].fd); 252 + return(-1); 253 + } 254 + 255 + fd[0].events = POLLOUT | POLLWRNORM; 256 + 257 + while (1) { 258 + int retval; 259 + static char buf[BUF_SIZE]; 260 + /* Read data from standard INPUT (stdin). */ 261 + int bytes_read = fread(buf, 1, BUF_SIZE, stdin); 262 + 263 + if (!bytes_read) { 264 + break; 265 + } 266 + 267 + while (bytes_read) { 268 + 269 + /* Wait for up to 1 second to sent data. */ 270 + retval = poll(fd, 1, 1000); 271 + 272 + /* Write data to printer gadget driver. */ 273 + if (retval && (fd[0].revents & POLLWRNORM)) { 274 + retval = write(fd[0].fd, buf, bytes_read); 275 + if (retval < 0) { 276 + printf("Error %d writing to %s\n", 277 + fd[0].fd, 278 + PRINTER_FILE); 279 + close(fd[0].fd); 280 + return(-1); 281 + } else { 282 + bytes_read -= retval; 283 + } 284 + 285 + } 286 + 287 + } 288 + 289 + } 290 + 291 + /* Wait until the data has been sent. */ 292 + fsync(fd[0].fd); 293 + 294 + /* Close the device file. */ 295 + close(fd[0].fd); 296 + 297 + return 0; 298 + } 299 + 300 + 301 + static int 302 + read_NB_printer_data() 303 + { 304 + int fd; 305 + static char buf[BUF_SIZE]; 306 + int bytes_read; 307 + 308 + /* Open device file for printer gadget. */ 309 + fd = open(PRINTER_FILE, O_RDWR|O_NONBLOCK); 310 + if (fd < 0) { 311 + printf("Error %d opening %s\n", fd, PRINTER_FILE); 312 + close(fd); 313 + return(-1); 314 + } 315 + 316 + while (1) { 317 + /* Read data from printer gadget driver. */ 318 + bytes_read = read(fd, buf, BUF_SIZE); 319 + if (bytes_read <= 0) { 320 + break; 321 + } 322 + 323 + /* Write data to standard OUTPUT (stdout). */ 324 + fwrite(buf, 1, bytes_read, stdout); 325 + fflush(stdout); 326 + } 327 + 328 + /* Close the device file. */ 329 + close(fd); 330 + 331 + return 0; 332 + } 333 + 334 + 335 + static int 336 + get_printer_status() 337 + { 338 + int retval; 339 + int fd; 340 + 341 + /* Open device file for printer gadget. */ 342 + fd = open(PRINTER_FILE, O_RDWR); 343 + if (fd < 0) { 344 + printf("Error %d opening %s\n", fd, PRINTER_FILE); 345 + close(fd); 346 + return(-1); 347 + } 348 + 349 + /* Make the IOCTL call. */ 350 + retval = ioctl(fd, GADGET_GET_PRINTER_STATUS); 351 + if (retval < 0) { 352 + fprintf(stderr, "ERROR: Failed to set printer status\n"); 353 + return(-1); 354 + } 355 + 356 + /* Close the device file. */ 357 + close(fd); 358 + 359 + return(retval); 360 + } 361 + 362 + 363 + static int 364 + set_printer_status(unsigned char buf, int clear_printer_status_bit) 365 + { 366 + int retval; 367 + int fd; 368 + 369 + retval = get_printer_status(); 370 + if (retval < 0) { 371 + fprintf(stderr, "ERROR: Failed to get printer status\n"); 372 + return(-1); 373 + } 374 + 375 + /* Open device file for printer gadget. */ 376 + fd = open(PRINTER_FILE, O_RDWR); 377 + 378 + if (fd < 0) { 379 + printf("Error %d opening %s\n", fd, PRINTER_FILE); 380 + close(fd); 381 + return(-1); 382 + } 383 + 384 + if (clear_printer_status_bit) { 385 + retval &= ~buf; 386 + } else { 387 + retval |= buf; 388 + } 389 + 390 + /* Make the IOCTL call. */ 391 + if (ioctl(fd, GADGET_SET_PRINTER_STATUS, (unsigned char)retval)) { 392 + fprintf(stderr, "ERROR: Failed to set printer status\n"); 393 + return(-1); 394 + } 395 + 396 + /* Close the device file. */ 397 + close(fd); 398 + 399 + return 0; 400 + } 401 + 402 + 403 + static int 404 + display_printer_status() 405 + { 406 + char printer_status; 407 + 408 + printer_status = get_printer_status(); 409 + if (printer_status < 0) { 410 + fprintf(stderr, "ERROR: Failed to get printer status\n"); 411 + return(-1); 412 + } 413 + 414 + printf("Printer status is:\n"); 415 + if (printer_status & PRINTER_SELECTED) { 416 + printf(" Printer is Selected\n"); 417 + } else { 418 + printf(" Printer is NOT Selected\n"); 419 + } 420 + if (printer_status & PRINTER_PAPER_EMPTY) { 421 + printf(" Paper is Out\n"); 422 + } else { 423 + printf(" Paper is Loaded\n"); 424 + } 425 + if (printer_status & PRINTER_NOT_ERROR) { 426 + printf(" Printer OK\n"); 427 + } else { 428 + printf(" Printer ERROR\n"); 429 + } 430 + 431 + return(0); 432 + } 433 + 434 + 435 + int 436 + main(int argc, char *argv[]) 437 + { 438 + int i; /* Looping var */ 439 + int retval = 0; 440 + 441 + /* No Args */ 442 + if (argc == 1) { 443 + usage(0); 444 + exit(0); 445 + } 446 + 447 + for (i = 1; i < argc && !retval; i ++) { 448 + 449 + if (argv[i][0] != '-') { 450 + continue; 451 + } 452 + 453 + if (!strcmp(argv[i], "-get_status")) { 454 + if (display_printer_status()) { 455 + retval = 1; 456 + } 457 + 458 + } else if (!strcmp(argv[i], "-paper_loaded")) { 459 + if (set_printer_status(PRINTER_PAPER_EMPTY, 1)) { 460 + retval = 1; 461 + } 462 + 463 + } else if (!strcmp(argv[i], "-paper_out")) { 464 + if (set_printer_status(PRINTER_PAPER_EMPTY, 0)) { 465 + retval = 1; 466 + } 467 + 468 + } else if (!strcmp(argv[i], "-selected")) { 469 + if (set_printer_status(PRINTER_SELECTED, 0)) { 470 + retval = 1; 471 + } 472 + 473 + } else if (!strcmp(argv[i], "-not_selected")) { 474 + if (set_printer_status(PRINTER_SELECTED, 1)) { 475 + retval = 1; 476 + } 477 + 478 + } else if (!strcmp(argv[i], "-error")) { 479 + if (set_printer_status(PRINTER_NOT_ERROR, 1)) { 480 + retval = 1; 481 + } 482 + 483 + } else if (!strcmp(argv[i], "-no_error")) { 484 + if (set_printer_status(PRINTER_NOT_ERROR, 0)) { 485 + retval = 1; 486 + } 487 + 488 + } else if (!strcmp(argv[i], "-read_data")) { 489 + if (read_printer_data()) { 490 + retval = 1; 491 + } 492 + 493 + } else if (!strcmp(argv[i], "-write_data")) { 494 + if (write_printer_data()) { 495 + retval = 1; 496 + } 497 + 498 + } else if (!strcmp(argv[i], "-NB_read_data")) { 499 + if (read_NB_printer_data()) { 500 + retval = 1; 501 + } 502 + 503 + } else { 504 + usage(argv[i]); 505 + retval = 1; 506 + } 507 + } 508 + 509 + exit(retval); 510 + }
+84
Documentation/usb/iuu_phoenix.txt
··· 1 + Infinity Usb Unlimited Readme 2 + ----------------------------- 3 + 4 + Hi all, 5 + 6 + 7 + This module provide a serial interface to use your 8 + IUU unit in phoenix mode. Loading this module will 9 + bring a ttyUSB[0-x] interface. This driver must be 10 + used by your favorite application to pilot the IUU 11 + 12 + This driver is still in beta stage, so bugs can 13 + occur and your system may freeze. As far I now, 14 + I never had any problem with it, but I'm not a real 15 + guru, so don't blame me if your system is unstable 16 + 17 + You can plug more than one IUU. Every unit will 18 + have his own device file(/dev/ttyUSB0,/dev/ttyUSB1,...) 19 + 20 + 21 + 22 + How to tune the reader speed ? 23 + 24 + A few parameters can be used at load time 25 + To use parameters, just unload the module if it is 26 + already loaded and use modprobe iuu_phoenix param=value. 27 + In case of prebuilt module, use the command 28 + insmod iuu_phoenix param=value. 29 + 30 + Example: 31 + 32 + modprobe iuu_phoenix clockmode=3 33 + 34 + The parameters are: 35 + 36 + parm: clockmode:1=3Mhz579,2=3Mhz680,3=6Mhz (int) 37 + parm: boost:overclock boost percent 100 to 500 (int) 38 + parm: cdmode:Card detect mode 0=none, 1=CD, 2=!CD, 3=DSR, 4=!DSR, 5=CTS, 6=!CTS, 7=RING, 8=!RING (int) 39 + parm: xmas:xmas color enabled or not (bool) 40 + parm: debug:Debug enabled or not (bool) 41 + 42 + - clockmode will provide 3 different base settings commonly adopted by 43 + different software: 44 + 1. 3Mhz579 45 + 2. 3Mhz680 46 + 3. 6Mhz 47 + 48 + - boost provide a way to overclock the reader ( my favorite :-) ) 49 + For example to have best performance than a simple clockmode=3, try this: 50 + 51 + modprobe boost=195 52 + 53 + This will put the reader in a base of 3Mhz579 but boosted a 195 % ! 54 + the real clock will be now : 6979050 Hz ( 6Mhz979 ) and will increase 55 + the speed to a score 10 to 20% better than the simple clockmode=3 !!! 56 + 57 + 58 + - cdmode permit to setup the signal used to inform the userland ( ioctl answer ) 59 + if the card is present or not. Eight signals are possible. 60 + 61 + - xmas is completely useless except for your eyes. This is one of my friend who was 62 + so sad to have a nice device like the iuu without seeing all color range available. 63 + So I have added this option to permit him to see a lot of color ( each activity change the color 64 + and the frequency randomly ) 65 + 66 + - debug will produce a lot of debugging messages... 67 + 68 + 69 + Last notes: 70 + 71 + Don't worry about the serial settings, the serial emulation 72 + is an abstraction, so use any speed or parity setting will 73 + work. ( This will not change anything ).Later I will perhaps 74 + use this settings to deduce de boost but is that feature 75 + really necessary ? 76 + The autodetect feature used is the serial CD. If that doesn't 77 + work for your software, disable detection mechanism in it. 78 + 79 + 80 + Have fun ! 81 + 82 + Alain Degreffe 83 + 84 + eczema(at)ecze.com
+2 -7
arch/arm/mach-pxa/tosa.c
··· 157 157 } 158 158 } 159 159 160 - static int tosa_udc_is_connected(void) 161 - { 162 - return ((GPLR(TOSA_GPIO_USB_IN) & GPIO_bit(TOSA_GPIO_USB_IN)) == 0); 163 - } 164 - 165 - 166 160 static struct pxa2xx_udc_mach_info udc_info __initdata = { 167 161 .udc_command = tosa_udc_command, 168 - .udc_is_connected = tosa_udc_is_connected, 162 + .gpio_vbus = TOSA_GPIO_USB_IN, 163 + .gpio_vbus_inverted = 1, 169 164 }; 170 165 171 166 /*
-23
drivers/block/ub.c
··· 922 922 usb_fill_bulk_urb(&sc->work_urb, sc->dev, sc->send_bulk_pipe, 923 923 bcb, US_BULK_CB_WRAP_LEN, ub_urb_complete, sc); 924 924 925 - /* Fill what we shouldn't be filling, because usb-storage did so. */ 926 - sc->work_urb.actual_length = 0; 927 - sc->work_urb.error_count = 0; 928 - sc->work_urb.status = 0; 929 - 930 925 if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) { 931 926 /* XXX Clear stalls */ 932 927 ub_complete(&sc->work_done); ··· 1308 1313 sc->last_pipe = pipe; 1309 1314 usb_fill_bulk_urb(&sc->work_urb, sc->dev, pipe, sg_virt(sg), 1310 1315 sg->length, ub_urb_complete, sc); 1311 - sc->work_urb.actual_length = 0; 1312 - sc->work_urb.error_count = 0; 1313 - sc->work_urb.status = 0; 1314 1316 1315 1317 if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) { 1316 1318 /* XXX Clear stalls */ ··· 1348 1356 sc->last_pipe = sc->recv_bulk_pipe; 1349 1357 usb_fill_bulk_urb(&sc->work_urb, sc->dev, sc->recv_bulk_pipe, 1350 1358 &sc->work_bcs, US_BULK_CS_WRAP_LEN, ub_urb_complete, sc); 1351 - sc->work_urb.actual_length = 0; 1352 - sc->work_urb.error_count = 0; 1353 - sc->work_urb.status = 0; 1354 1359 1355 1360 if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) { 1356 1361 /* XXX Clear stalls */ ··· 1462 1473 1463 1474 usb_fill_control_urb(&sc->work_urb, sc->dev, sc->send_ctrl_pipe, 1464 1475 (unsigned char*) cr, NULL, 0, ub_urb_complete, sc); 1465 - sc->work_urb.actual_length = 0; 1466 - sc->work_urb.error_count = 0; 1467 - sc->work_urb.status = 0; 1468 1476 1469 1477 if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) { 1470 1478 ub_complete(&sc->work_done); ··· 1939 1953 1940 1954 usb_fill_control_urb(&sc->work_urb, sc->dev, sc->send_ctrl_pipe, 1941 1955 (unsigned char*) cr, NULL, 0, ub_probe_urb_complete, &compl); 1942 - sc->work_urb.actual_length = 0; 1943 - sc->work_urb.error_count = 0; 1944 - sc->work_urb.status = 0; 1945 1956 1946 1957 if ((rc = usb_submit_urb(&sc->work_urb, GFP_KERNEL)) != 0) { 1947 1958 printk(KERN_WARNING ··· 1990 2007 1991 2008 usb_fill_control_urb(&sc->work_urb, sc->dev, sc->recv_ctrl_pipe, 1992 2009 (unsigned char*) cr, p, 1, ub_probe_urb_complete, &compl); 1993 - sc->work_urb.actual_length = 0; 1994 - sc->work_urb.error_count = 0; 1995 - sc->work_urb.status = 0; 1996 2010 1997 2011 if ((rc = usb_submit_urb(&sc->work_urb, GFP_KERNEL)) != 0) 1998 2012 goto err_submit; ··· 2057 2077 2058 2078 usb_fill_control_urb(&sc->work_urb, sc->dev, sc->send_ctrl_pipe, 2059 2079 (unsigned char*) cr, NULL, 0, ub_probe_urb_complete, &compl); 2060 - sc->work_urb.actual_length = 0; 2061 - sc->work_urb.error_count = 0; 2062 - sc->work_urb.status = 0; 2063 2080 2064 2081 if ((rc = usb_submit_urb(&sc->work_urb, GFP_KERNEL)) != 0) { 2065 2082 printk(KERN_WARNING
+5
drivers/usb/Kconfig
··· 42 42 default y if PPC_MPC52xx 43 43 # MIPS: 44 44 default y if SOC_AU1X00 45 + # SH: 46 + default y if CPU_SUBTYPE_SH7720 47 + default y if CPU_SUBTYPE_SH7721 48 + default y if CPU_SUBTYPE_SH7763 45 49 # more: 46 50 default PCI 47 51 ··· 54 50 boolean 55 51 default y if PPC_83xx 56 52 default y if SOC_AU1200 53 + default y if ARCH_IXP4XX 57 54 default PCI 58 55 59 56 # ARM SA1111 chips have a non-PCI based "OHCI-compatible" USB host interface.
+4 -5
drivers/usb/atm/Kconfig
··· 2 2 # USB/ATM DSL configuration 3 3 # 4 4 5 - menu "USB DSL modem support" 6 - depends on USB 7 - 8 - config USB_ATM 5 + menuconfig USB_ATM 9 6 tristate "USB DSL modem support" 10 7 depends on USB && ATM 11 8 select CRC32 ··· 14 17 15 18 To compile this driver as a module, choose M here: the 16 19 module will be called usbatm. 20 + 21 + if USB_ATM 17 22 18 23 config USB_SPEEDTOUCH 19 24 tristate "Speedtouch USB support" ··· 69 70 To compile this driver as a module, choose M here: the 70 71 module will be called xusbatm. 71 72 72 - endmenu 73 + endif # USB_ATM
+3 -3
drivers/usb/atm/ueagle-atm.c
··· 999 999 bi.dwAddress = swab32(blockidx->PageAddress); 1000 1000 1001 1001 uea_dbg(INS_TO_USBDEV(sc), 1002 - "sending block %u for DSP page %u size %u adress %x\n", 1002 + "sending block %u for DSP page %u size %u address %x\n", 1003 1003 blockno, pageno, blocksize, le32_to_cpu(blockidx->PageAddress)); 1004 1004 1005 1005 /* send block info through the IDMA pipe */ ··· 1990 1990 return; 1991 1991 1992 1992 bad2: 1993 - uea_err(INS_TO_USBDEV(sc), "unexpected cmv received," 1993 + uea_err(INS_TO_USBDEV(sc), "unexpected cmv received, " 1994 1994 "Function : %d, Subfunction : %d\n", 1995 1995 E1_FUNCTION_TYPE(cmv->bFunction), 1996 1996 E1_FUNCTION_SUBTYPE(cmv->bFunction)); ··· 2038 2038 return; 2039 2039 2040 2040 bad2: 2041 - uea_err(INS_TO_USBDEV(sc), "unexpected cmv received," 2041 + uea_err(INS_TO_USBDEV(sc), "unexpected cmv received, " 2042 2042 "Function : %d, Subfunction : %d\n", 2043 2043 E4_FUNCTION_TYPE(cmv->wFunction), 2044 2044 E4_FUNCTION_SUBTYPE(cmv->wFunction));
+78 -16
drivers/usb/class/cdc-acm.c
··· 496 496 otherwise it is scheduled, and with high data rates data can get lost. */ 497 497 tty->low_latency = 1; 498 498 499 + if (usb_autopm_get_interface(acm->control)) { 500 + mutex_unlock(&open_mutex); 501 + return -EIO; 502 + } 503 + 504 + mutex_lock(&acm->mutex); 505 + mutex_unlock(&open_mutex); 499 506 if (acm->used++) { 507 + usb_autopm_put_interface(acm->control); 500 508 goto done; 501 509 } 510 + 502 511 503 512 acm->ctrlurb->dev = acm->dev; 504 513 if (usb_submit_urb(acm->ctrlurb, GFP_KERNEL)) { ··· 535 526 536 527 done: 537 528 err_out: 538 - mutex_unlock(&open_mutex); 529 + mutex_unlock(&acm->mutex); 539 530 return rv; 540 531 541 532 full_bailout: 542 533 usb_kill_urb(acm->ctrlurb); 543 534 bail_out: 535 + usb_autopm_put_interface(acm->control); 544 536 acm->used--; 545 - mutex_unlock(&open_mutex); 537 + mutex_unlock(&acm->mutex); 546 538 return -EIO; 547 539 } 548 540 ··· 580 570 usb_kill_urb(acm->writeurb); 581 571 for (i = 0; i < nr; i++) 582 572 usb_kill_urb(acm->ru[i].urb); 573 + usb_autopm_put_interface(acm->control); 583 574 } else 584 575 acm_tty_unregister(acm); 585 576 } ··· 915 904 } 916 905 917 906 if (data_interface_num != call_interface_num) 918 - dev_dbg(&intf->dev,"Seperate call control interface. That is not fully supported.\n"); 907 + dev_dbg(&intf->dev,"Separate call control interface. That is not fully supported.\n"); 919 908 920 909 skip_normal_probe: 921 910 ··· 991 980 spin_lock_init(&acm->throttle_lock); 992 981 spin_lock_init(&acm->write_lock); 993 982 spin_lock_init(&acm->read_lock); 983 + mutex_init(&acm->mutex); 994 984 acm->write_ready = 1; 995 985 acm->rx_endpoint = usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress); 996 986 ··· 1108 1096 return -ENOMEM; 1109 1097 } 1110 1098 1099 + static void stop_data_traffic(struct acm *acm) 1100 + { 1101 + int i; 1102 + 1103 + tasklet_disable(&acm->urb_task); 1104 + 1105 + usb_kill_urb(acm->ctrlurb); 1106 + usb_kill_urb(acm->writeurb); 1107 + for (i = 0; i < acm->rx_buflimit; i++) 1108 + usb_kill_urb(acm->ru[i].urb); 1109 + 1110 + INIT_LIST_HEAD(&acm->filled_read_bufs); 1111 + INIT_LIST_HEAD(&acm->spare_read_bufs); 1112 + 1113 + tasklet_enable(&acm->urb_task); 1114 + 1115 + cancel_work_sync(&acm->work); 1116 + } 1117 + 1111 1118 static void acm_disconnect(struct usb_interface *intf) 1112 1119 { 1113 1120 struct acm *acm = usb_get_intfdata(intf); ··· 1154 1123 usb_set_intfdata(acm->control, NULL); 1155 1124 usb_set_intfdata(acm->data, NULL); 1156 1125 1157 - tasklet_disable(&acm->urb_task); 1158 - 1159 - usb_kill_urb(acm->ctrlurb); 1160 - usb_kill_urb(acm->writeurb); 1161 - for (i = 0; i < acm->rx_buflimit; i++) 1162 - usb_kill_urb(acm->ru[i].urb); 1163 - 1164 - INIT_LIST_HEAD(&acm->filled_read_bufs); 1165 - INIT_LIST_HEAD(&acm->spare_read_bufs); 1166 - 1167 - tasklet_enable(&acm->urb_task); 1168 - 1169 - flush_scheduled_work(); /* wait for acm_softint */ 1126 + stop_data_traffic(acm); 1170 1127 1171 1128 acm_write_buffers_free(acm); 1172 1129 usb_buffer_free(usb_dev, acm->ctrlsize, acm->ctrl_buffer, acm->ctrl_dma); ··· 1175 1156 tty_hangup(acm->tty); 1176 1157 } 1177 1158 1159 + static int acm_suspend(struct usb_interface *intf, pm_message_t message) 1160 + { 1161 + struct acm *acm = usb_get_intfdata(intf); 1162 + 1163 + if (acm->susp_count++) 1164 + return 0; 1165 + /* 1166 + we treat opened interfaces differently, 1167 + we must guard against open 1168 + */ 1169 + mutex_lock(&acm->mutex); 1170 + 1171 + if (acm->used) 1172 + stop_data_traffic(acm); 1173 + 1174 + mutex_unlock(&acm->mutex); 1175 + return 0; 1176 + } 1177 + 1178 + static int acm_resume(struct usb_interface *intf) 1179 + { 1180 + struct acm *acm = usb_get_intfdata(intf); 1181 + int rv = 0; 1182 + 1183 + if (--acm->susp_count) 1184 + return 0; 1185 + 1186 + mutex_lock(&acm->mutex); 1187 + if (acm->used) { 1188 + rv = usb_submit_urb(acm->ctrlurb, GFP_NOIO); 1189 + if (rv < 0) 1190 + goto err_out; 1191 + 1192 + tasklet_schedule(&acm->urb_task); 1193 + } 1194 + 1195 + err_out: 1196 + mutex_unlock(&acm->mutex); 1197 + return rv; 1198 + } 1178 1199 /* 1179 1200 * USB driver structure. 1180 1201 */ ··· 1267 1208 .name = "cdc_acm", 1268 1209 .probe = acm_probe, 1269 1210 .disconnect = acm_disconnect, 1211 + .suspend = acm_suspend, 1212 + .resume = acm_resume, 1270 1213 .id_table = acm_ids, 1214 + .supports_autosuspend = 1, 1271 1215 }; 1272 1216 1273 1217 /*
+2
drivers/usb/class/cdc-acm.h
··· 107 107 int write_used; /* number of non-empty write buffers */ 108 108 int write_ready; /* write urb is not running */ 109 109 spinlock_t write_lock; 110 + struct mutex mutex; 110 111 struct usb_cdc_line_coding line; /* bits, stop, parity */ 111 112 struct work_struct work; /* work queue entry for line discipline waking up */ 112 113 struct tasklet_struct urb_task; /* rx processing */ ··· 121 120 unsigned char throttle; /* throttled by tty layer */ 122 121 unsigned char clocal; /* termios CLOCAL */ 123 122 unsigned int ctrl_caps; /* control capabilities from the class specific header */ 123 + unsigned int susp_count; /* number of suspended interfaces */ 124 124 }; 125 125 126 126 #define CDC_DATA_INTERFACE_TYPE 0x0a
+15
drivers/usb/core/Kconfig
··· 9 9 of debug messages to the system log. Select this if you are having a 10 10 problem with USB support and want to see more of what is going on. 11 11 12 + config USB_ANNOUNCE_NEW_DEVICES 13 + bool "USB announce new devices" 14 + depends on USB 15 + default N 16 + help 17 + Say Y here if you want the USB core to always announce the 18 + idVendor, idProduct, Manufacturer, Product, and SerialNumber 19 + strings for every new USB device to the syslog. This option is 20 + usually used by distro vendors to help with debugging and to 21 + let users know what specific device was added to the machine 22 + in what location. 23 + 24 + If you do not want this kind of information sent to the system 25 + log, or have any doubts about this, say N here. 26 + 12 27 comment "Miscellaneous USB options" 13 28 depends on USB 14 29
+12 -8
drivers/usb/core/buffer.c
··· 53 53 char name[16]; 54 54 int i, size; 55 55 56 - if (!hcd->self.controller->dma_mask) 56 + if (!hcd->self.controller->dma_mask && 57 + !(hcd->driver->flags & HCD_LOCAL_MEM)) 57 58 return 0; 58 59 59 - for (i = 0; i < HCD_BUFFER_POOLS; i++) { 60 - if (!(size = pool_max [i])) 60 + for (i = 0; i < HCD_BUFFER_POOLS; i++) { 61 + size = pool_max[i]; 62 + if (!size) 61 63 continue; 62 64 snprintf(name, sizeof name, "buffer-%d", size); 63 65 hcd->pool[i] = dma_pool_create(name, hcd->self.controller, ··· 82 80 */ 83 81 void hcd_buffer_destroy(struct usb_hcd *hcd) 84 82 { 85 - int i; 83 + int i; 86 84 87 - for (i = 0; i < HCD_BUFFER_POOLS; i++) { 88 - struct dma_pool *pool = hcd->pool[i]; 85 + for (i = 0; i < HCD_BUFFER_POOLS; i++) { 86 + struct dma_pool *pool = hcd->pool[i]; 89 87 if (pool) { 90 88 dma_pool_destroy(pool); 91 89 hcd->pool[i] = NULL; ··· 109 107 int i; 110 108 111 109 /* some USB hosts just use PIO */ 112 - if (!bus->controller->dma_mask) { 110 + if (!bus->controller->dma_mask && 111 + !(hcd->driver->flags & HCD_LOCAL_MEM)) { 113 112 *dma = ~(dma_addr_t) 0; 114 113 return kmalloc(size, mem_flags); 115 114 } ··· 135 132 if (!addr) 136 133 return; 137 134 138 - if (!bus->controller->dma_mask) { 135 + if (!bus->controller->dma_mask && 136 + !(hcd->driver->flags & HCD_LOCAL_MEM)) { 139 137 kfree(addr); 140 138 return; 141 139 }
+8 -6
drivers/usb/core/config.c
··· 238 238 239 239 /* Allocate space for the right(?) number of endpoints */ 240 240 num_ep = num_ep_orig = alt->desc.bNumEndpoints; 241 - alt->desc.bNumEndpoints = 0; // Use as a counter 241 + alt->desc.bNumEndpoints = 0; /* Use as a counter */ 242 242 if (num_ep > USB_MAXENDPOINTS) { 243 243 dev_warn(ddev, "too many endpoints for config %d interface %d " 244 244 "altsetting %d: %d, using maximum allowed: %d\n", ··· 246 246 num_ep = USB_MAXENDPOINTS; 247 247 } 248 248 249 - if (num_ep > 0) { /* Can't allocate 0 bytes */ 249 + if (num_ep > 0) { 250 + /* Can't allocate 0 bytes */ 250 251 len = sizeof(struct usb_host_endpoint) * num_ep; 251 252 alt->endpoint = kzalloc(len, GFP_KERNEL); 252 253 if (!alt->endpoint) ··· 476 475 return 0; 477 476 } 478 477 479 - // hub-only!! ... and only exported for reset/reinit path. 480 - // otherwise used internally on disconnect/destroy path 478 + /* hub-only!! ... and only exported for reset/reinit path. 479 + * otherwise used internally on disconnect/destroy path 480 + */ 481 481 void usb_destroy_configuration(struct usb_device *dev) 482 482 { 483 483 int c, i; ··· 500 498 kfree(cf->string); 501 499 for (i = 0; i < cf->desc.bNumInterfaces; i++) { 502 500 if (cf->intf_cache[i]) 503 - kref_put(&cf->intf_cache[i]->ref, 501 + kref_put(&cf->intf_cache[i]->ref, 504 502 usb_release_interface_cache); 505 503 } 506 504 } ··· 527 525 unsigned int cfgno, length; 528 526 unsigned char *buffer; 529 527 unsigned char *bigbuffer; 530 - struct usb_config_descriptor *desc; 528 + struct usb_config_descriptor *desc; 531 529 532 530 cfgno = 0; 533 531 if (dev->authorized == 0) /* Not really an error */
+82 -72
drivers/usb/core/devices.c
··· 89 89 static const char *format_bandwidth = 90 90 /* B: Alloc=ddd/ddd us (xx%), #Int=ddd, #Iso=ddd */ 91 91 "B: Alloc=%3d/%3d us (%2d%%), #Int=%3d, #Iso=%3d\n"; 92 - 92 + 93 93 static const char *format_device1 = 94 94 /* D: Ver=xx.xx Cls=xx(sssss) Sub=xx Prot=xx MxPS=dd #Cfgs=dd */ 95 95 "D: Ver=%2x.%02x Cls=%02x(%-5s) Sub=%02x Prot=%02x MxPS=%2d #Cfgs=%3d\n"; ··· 101 101 static const char *format_config = 102 102 /* C: #Ifs=dd Cfg#=dd Atr=xx MPwr=dddmA */ 103 103 "C:%c #Ifs=%2d Cfg#=%2d Atr=%02x MxPwr=%3dmA\n"; 104 - 104 + 105 105 static const char *format_iad = 106 106 /* A: FirstIf#=dd IfCount=dd Cls=xx(sssss) Sub=xx Prot=xx */ 107 107 "A: FirstIf#=%2d IfCount=%2d Cls=%02x(%-5s) Sub=%02x Prot=%02x\n"; ··· 122 122 */ 123 123 124 124 static DECLARE_WAIT_QUEUE_HEAD(deviceconndiscwq); 125 - static unsigned int conndiscevcnt = 0; 125 + static unsigned int conndiscevcnt; 126 126 127 127 /* this struct stores the poll state for <mountpoint>/devices pollers */ 128 128 struct usb_device_status { ··· 172 172 return clas_info[ix].class_name; 173 173 } 174 174 175 - static char *usb_dump_endpoint_descriptor( 176 - int speed, 177 - char *start, 178 - char *end, 179 - const struct usb_endpoint_descriptor *desc 180 - ) 175 + static char *usb_dump_endpoint_descriptor(int speed, char *start, char *end, 176 + const struct usb_endpoint_descriptor *desc) 181 177 { 182 178 char dir, unit, *type; 183 179 unsigned interval, bandwidth = 1; ··· 231 235 232 236 start += sprintf(start, format_endpt, desc->bEndpointAddress, dir, 233 237 desc->bmAttributes, type, 234 - (le16_to_cpu(desc->wMaxPacketSize) & 0x07ff) * bandwidth, 238 + (le16_to_cpu(desc->wMaxPacketSize) & 0x07ff) * 239 + bandwidth, 235 240 interval, unit); 236 241 return start; 237 242 } 238 243 239 244 static char *usb_dump_interface_descriptor(char *start, char *end, 240 - const struct usb_interface_cache *intfc, 241 - const struct usb_interface *iface, 242 - int setno) 245 + const struct usb_interface_cache *intfc, 246 + const struct usb_interface *iface, 247 + int setno) 243 248 { 244 - const struct usb_interface_descriptor *desc = &intfc->altsetting[setno].desc; 249 + const struct usb_interface_descriptor *desc; 245 250 const char *driver_name = ""; 246 251 int active = 0; 247 252 248 253 if (start > end) 249 254 return start; 255 + desc = &intfc->altsetting[setno].desc; 250 256 if (iface) { 251 257 driver_name = (iface->dev.driver 252 258 ? iface->dev.driver->name ··· 268 270 return start; 269 271 } 270 272 271 - static char *usb_dump_interface( 272 - int speed, 273 - char *start, 274 - char *end, 275 - const struct usb_interface_cache *intfc, 276 - const struct usb_interface *iface, 277 - int setno 278 - ) { 273 + static char *usb_dump_interface(int speed, char *start, char *end, 274 + const struct usb_interface_cache *intfc, 275 + const struct usb_interface *iface, int setno) 276 + { 279 277 const struct usb_host_interface *desc = &intfc->altsetting[setno]; 280 278 int i; 281 279 ··· 286 292 } 287 293 288 294 static char *usb_dump_iad_descriptor(char *start, char *end, 289 - const struct usb_interface_assoc_descriptor *iad) 295 + const struct usb_interface_assoc_descriptor *iad) 290 296 { 291 297 if (start > end) 292 298 return start; ··· 305 311 * 1. marking active interface altsettings (code lists all, but should mark 306 312 * which ones are active, if any) 307 313 */ 308 - 309 - static char *usb_dump_config_descriptor(char *start, char *end, const struct usb_config_descriptor *desc, int active) 314 + static char *usb_dump_config_descriptor(char *start, char *end, 315 + const struct usb_config_descriptor *desc, 316 + int active) 310 317 { 311 318 if (start > end) 312 319 return start; 313 320 start += sprintf(start, format_config, 314 - active ? '*' : ' ', /* mark active/actual/current cfg. */ 321 + /* mark active/actual/current cfg. */ 322 + active ? '*' : ' ', 315 323 desc->bNumInterfaces, 316 324 desc->bConfigurationValue, 317 325 desc->bmAttributes, ··· 321 325 return start; 322 326 } 323 327 324 - static char *usb_dump_config ( 325 - int speed, 326 - char *start, 327 - char *end, 328 - const struct usb_host_config *config, 329 - int active 330 - ) 328 + static char *usb_dump_config(int speed, char *start, char *end, 329 + const struct usb_host_config *config, int active) 331 330 { 332 331 int i, j; 333 332 struct usb_interface_cache *intfc; ··· 330 339 331 340 if (start > end) 332 341 return start; 333 - if (!config) /* getting these some in 2.3.7; none in 2.3.6 */ 342 + if (!config) 343 + /* getting these some in 2.3.7; none in 2.3.6 */ 334 344 return start + sprintf(start, "(null Cfg. desc.)\n"); 335 345 start = usb_dump_config_descriptor(start, end, &config->desc, active); 336 346 for (i = 0; i < USB_MAXIADS; i++) { ··· 356 364 /* 357 365 * Dump the different USB descriptors. 358 366 */ 359 - static char *usb_dump_device_descriptor(char *start, char *end, const struct usb_device_descriptor *desc) 367 + static char *usb_dump_device_descriptor(char *start, char *end, 368 + const struct usb_device_descriptor *desc) 360 369 { 361 370 u16 bcdUSB = le16_to_cpu(desc->bcdUSB); 362 371 u16 bcdDevice = le16_to_cpu(desc->bcdDevice); ··· 367 374 start += sprintf(start, format_device1, 368 375 bcdUSB >> 8, bcdUSB & 0xff, 369 376 desc->bDeviceClass, 370 - class_decode (desc->bDeviceClass), 377 + class_decode(desc->bDeviceClass), 371 378 desc->bDeviceSubClass, 372 379 desc->bDeviceProtocol, 373 380 desc->bMaxPacketSize0, ··· 384 391 /* 385 392 * Dump the different strings that this device holds. 386 393 */ 387 - static char *usb_dump_device_strings(char *start, char *end, struct usb_device *dev) 394 + static char *usb_dump_device_strings(char *start, char *end, 395 + struct usb_device *dev) 388 396 { 389 397 if (start > end) 390 398 return start; 391 399 if (dev->manufacturer) 392 - start += sprintf(start, format_string_manufacturer, dev->manufacturer); 400 + start += sprintf(start, format_string_manufacturer, 401 + dev->manufacturer); 393 402 if (start > end) 394 403 goto out; 395 404 if (dev->product) ··· 400 405 goto out; 401 406 #ifdef ALLOW_SERIAL_NUMBER 402 407 if (dev->serial) 403 - start += sprintf(start, format_string_serialnumber, dev->serial); 408 + start += sprintf(start, format_string_serialnumber, 409 + dev->serial); 404 410 #endif 405 411 out: 406 412 return start; ··· 413 417 414 418 if (start > end) 415 419 return start; 416 - 420 + 417 421 start = usb_dump_device_descriptor(start, end, &dev->descriptor); 418 422 419 423 if (start > end) 420 424 return start; 421 - 425 + 422 426 start = usb_dump_device_strings(start, end, dev); 423 427 424 428 for (i = 0; i < dev->descriptor.bNumConfigurations; i++) { ··· 435 439 436 440 #ifdef PROC_EXTRA /* TBD: may want to add this code later */ 437 441 438 - static char *usb_dump_hub_descriptor(char *start, char *end, const struct usb_hub_descriptor * desc) 442 + static char *usb_dump_hub_descriptor(char *start, char *end, 443 + const struct usb_hub_descriptor *desc) 439 444 { 440 445 int leng = USB_DT_HUB_NONVAR_SIZE; 441 446 unsigned char *ptr = (unsigned char *)desc; ··· 452 455 return start; 453 456 } 454 457 455 - static char *usb_dump_string(char *start, char *end, const struct usb_device *dev, char *id, int index) 458 + static char *usb_dump_string(char *start, char *end, 459 + const struct usb_device *dev, char *id, int index) 456 460 { 457 461 if (start > end) 458 462 return start; 459 463 start += sprintf(start, "Interface:"); 460 - if (index <= dev->maxstring && dev->stringindex && dev->stringindex[index]) 461 - start += sprintf(start, "%s: %.100s ", id, dev->stringindex[index]); 464 + if (index <= dev->maxstring && dev->stringindex && 465 + dev->stringindex[index]) 466 + start += sprintf(start, "%s: %.100s ", id, 467 + dev->stringindex[index]); 462 468 return start; 463 469 } 464 470 ··· 476 476 * file_offset - the offset into the devices file on completion 477 477 * The caller must own the device lock. 478 478 */ 479 - static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, loff_t *skip_bytes, loff_t *file_offset, 480 - struct usb_device *usbdev, struct usb_bus *bus, int level, int index, int count) 479 + static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, 480 + loff_t *skip_bytes, loff_t *file_offset, 481 + struct usb_device *usbdev, struct usb_bus *bus, 482 + int level, int index, int count) 481 483 { 482 484 int chix; 483 485 int ret, cnt = 0; ··· 487 485 char *pages_start, *data_end, *speed; 488 486 unsigned int length; 489 487 ssize_t total_written = 0; 490 - 488 + 491 489 /* don't bother with anything else if we're not writing any data */ 492 490 if (*nbytes <= 0) 493 491 return 0; 494 - 492 + 495 493 if (level > MAX_TOPO_LEVEL) 496 494 return 0; 497 - /* allocate 2^1 pages = 8K (on i386); should be more than enough for one device */ 498 - if (!(pages_start = (char*) __get_free_pages(GFP_KERNEL,1))) 499 - return -ENOMEM; 500 - 495 + /* allocate 2^1 pages = 8K (on i386); 496 + * should be more than enough for one device */ 497 + pages_start = (char *)__get_free_pages(GFP_KERNEL, 1); 498 + if (!pages_start) 499 + return -ENOMEM; 500 + 501 501 if (usbdev->parent && usbdev->parent->devnum != -1) 502 502 parent_devnum = usbdev->parent->devnum; 503 503 /* ··· 545 541 bus->bandwidth_allocated, max, 546 542 (100 * bus->bandwidth_allocated + max / 2) 547 543 / max, 548 - bus->bandwidth_int_reqs, 549 - bus->bandwidth_isoc_reqs); 550 - 544 + bus->bandwidth_int_reqs, 545 + bus->bandwidth_isoc_reqs); 546 + 551 547 } 552 - data_end = usb_dump_desc(data_end, pages_start + (2 * PAGE_SIZE) - 256, usbdev); 553 - 548 + data_end = usb_dump_desc(data_end, pages_start + (2 * PAGE_SIZE) - 256, 549 + usbdev); 550 + 554 551 if (data_end > (pages_start + (2 * PAGE_SIZE) - 256)) 555 552 data_end += sprintf(data_end, "(truncated)\n"); 556 - 553 + 557 554 length = data_end - pages_start; 558 555 /* if we can start copying some data to the user */ 559 556 if (length > *skip_bytes) { ··· 572 567 *skip_bytes = 0; 573 568 } else 574 569 *skip_bytes -= length; 575 - 570 + 576 571 free_pages((unsigned long)pages_start, 1); 577 - 572 + 578 573 /* Now look at all of this device's children. */ 579 574 for (chix = 0; chix < usbdev->maxchild; chix++) { 580 575 struct usb_device *childdev = usbdev->children[chix]; 581 576 582 577 if (childdev) { 583 578 usb_lock_device(childdev); 584 - ret = usb_device_dump(buffer, nbytes, skip_bytes, file_offset, childdev, 585 - bus, level + 1, chix, ++cnt); 579 + ret = usb_device_dump(buffer, nbytes, skip_bytes, 580 + file_offset, childdev, bus, 581 + level + 1, chix, ++cnt); 586 582 usb_unlock_device(childdev); 587 583 if (ret == -EFAULT) 588 584 return total_written; ··· 593 587 return total_written; 594 588 } 595 589 596 - static ssize_t usb_device_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) 590 + static ssize_t usb_device_read(struct file *file, char __user *buf, 591 + size_t nbytes, loff_t *ppos) 597 592 { 598 593 struct usb_bus *bus; 599 594 ssize_t ret, total_written = 0; ··· 614 607 if (!bus->root_hub) 615 608 continue; 616 609 usb_lock_device(bus->root_hub); 617 - ret = usb_device_dump(&buf, &nbytes, &skip_bytes, ppos, bus->root_hub, bus, 0, 0, 0); 610 + ret = usb_device_dump(&buf, &nbytes, &skip_bytes, ppos, 611 + bus->root_hub, bus, 0, 0, 0); 618 612 usb_unlock_device(bus->root_hub); 619 613 if (ret < 0) { 620 614 mutex_unlock(&usb_bus_list_lock); ··· 628 620 } 629 621 630 622 /* Kernel lock for "lastev" protection */ 631 - static unsigned int usb_device_poll(struct file *file, struct poll_table_struct *wait) 623 + static unsigned int usb_device_poll(struct file *file, 624 + struct poll_table_struct *wait) 632 625 { 633 626 struct usb_device_status *st = file->private_data; 634 627 unsigned int mask = 0; ··· 638 629 if (!st) { 639 630 st = kmalloc(sizeof(struct usb_device_status), GFP_KERNEL); 640 631 641 - /* we may have dropped BKL - need to check for having lost the race */ 632 + /* we may have dropped BKL - 633 + * need to check for having lost the race */ 642 634 if (file->private_data) { 643 635 kfree(st); 644 636 st = file->private_data; ··· 662 652 } 663 653 lost_race: 664 654 if (file->f_mode & FMODE_READ) 665 - poll_wait(file, &deviceconndiscwq, wait); 655 + poll_wait(file, &deviceconndiscwq, wait); 666 656 if (st->lastev != conndiscevcnt) 667 657 mask |= POLLIN; 668 658 st->lastev = conndiscevcnt; ··· 672 662 673 663 static int usb_device_open(struct inode *inode, struct file *file) 674 664 { 675 - file->private_data = NULL; 676 - return 0; 665 + file->private_data = NULL; 666 + return 0; 677 667 } 678 668 679 669 static int usb_device_release(struct inode *inode, struct file *file) 680 670 { 681 671 kfree(file->private_data); 682 672 file->private_data = NULL; 683 - return 0; 673 + return 0; 684 674 } 685 675 686 - static loff_t usb_device_lseek(struct file * file, loff_t offset, int orig) 676 + static loff_t usb_device_lseek(struct file *file, loff_t offset, int orig) 687 677 { 688 678 loff_t ret; 689 679
+208 -149
drivers/usb/core/devio.c
··· 75 75 u32 secid; 76 76 }; 77 77 78 - static int usbfs_snoop = 0; 79 - module_param (usbfs_snoop, bool, S_IRUGO | S_IWUSR); 80 - MODULE_PARM_DESC (usbfs_snoop, "true to log all usbfs traffic"); 78 + static int usbfs_snoop; 79 + module_param(usbfs_snoop, bool, S_IRUGO | S_IWUSR); 80 + MODULE_PARM_DESC(usbfs_snoop, "true to log all usbfs traffic"); 81 81 82 82 #define snoop(dev, format, arg...) \ 83 83 do { \ 84 84 if (usbfs_snoop) \ 85 - dev_info( dev , format , ## arg); \ 85 + dev_info(dev , format , ## arg); \ 86 86 } while (0) 87 87 88 88 #define USB_DEVICE_DEV MKDEV(USB_DEVICE_MAJOR, 0) ··· 90 90 91 91 #define MAX_USBFS_BUFFER_SIZE 16384 92 92 93 - static inline int connected (struct dev_state *ps) 93 + static inline int connected(struct dev_state *ps) 94 94 { 95 95 return (!list_empty(&ps->list) && 96 96 ps->dev->state != USB_STATE_NOTATTACHED); ··· 120 120 return ret; 121 121 } 122 122 123 - static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) 123 + static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes, 124 + loff_t *ppos) 124 125 { 125 126 struct dev_state *ps = file->private_data; 126 127 struct usb_device *dev = ps->dev; ··· 141 140 } 142 141 143 142 if (pos < sizeof(struct usb_device_descriptor)) { 144 - struct usb_device_descriptor temp_desc ; /* 18 bytes - fits on the stack */ 143 + /* 18 bytes - fits on the stack */ 144 + struct usb_device_descriptor temp_desc; 145 145 146 146 memcpy(&temp_desc, &dev->descriptor, sizeof(dev->descriptor)); 147 147 le16_to_cpus(&temp_desc.bcdUSB); ··· 212 210 213 211 static struct async *alloc_async(unsigned int numisoframes) 214 212 { 215 - unsigned int assize = sizeof(struct async) + numisoframes * sizeof(struct usb_iso_packet_descriptor); 216 - struct async *as = kzalloc(assize, GFP_KERNEL); 213 + struct async *as; 217 214 218 - if (!as) 219 - return NULL; 215 + as = kzalloc(sizeof(struct async), GFP_KERNEL); 216 + if (!as) 217 + return NULL; 220 218 as->urb = usb_alloc_urb(numisoframes, GFP_KERNEL); 221 219 if (!as->urb) { 222 220 kfree(as); 223 221 return NULL; 224 222 } 225 - return as; 223 + return as; 226 224 } 227 225 228 226 static void free_async(struct async *as) ··· 236 234 237 235 static inline void async_newpending(struct async *as) 238 236 { 239 - struct dev_state *ps = as->ps; 240 - unsigned long flags; 241 - 242 - spin_lock_irqsave(&ps->lock, flags); 243 - list_add_tail(&as->asynclist, &ps->async_pending); 244 - spin_unlock_irqrestore(&ps->lock, flags); 237 + struct dev_state *ps = as->ps; 238 + unsigned long flags; 239 + 240 + spin_lock_irqsave(&ps->lock, flags); 241 + list_add_tail(&as->asynclist, &ps->async_pending); 242 + spin_unlock_irqrestore(&ps->lock, flags); 245 243 } 246 244 247 245 static inline void async_removepending(struct async *as) 248 246 { 249 - struct dev_state *ps = as->ps; 250 - unsigned long flags; 251 - 252 - spin_lock_irqsave(&ps->lock, flags); 253 - list_del_init(&as->asynclist); 254 - spin_unlock_irqrestore(&ps->lock, flags); 247 + struct dev_state *ps = as->ps; 248 + unsigned long flags; 249 + 250 + spin_lock_irqsave(&ps->lock, flags); 251 + list_del_init(&as->asynclist); 252 + spin_unlock_irqrestore(&ps->lock, flags); 255 253 } 256 254 257 255 static inline struct async *async_getcompleted(struct dev_state *ps) 258 256 { 259 - unsigned long flags; 260 - struct async *as = NULL; 257 + unsigned long flags; 258 + struct async *as = NULL; 261 259 262 - spin_lock_irqsave(&ps->lock, flags); 263 - if (!list_empty(&ps->async_completed)) { 264 - as = list_entry(ps->async_completed.next, struct async, asynclist); 265 - list_del_init(&as->asynclist); 266 - } 267 - spin_unlock_irqrestore(&ps->lock, flags); 268 - return as; 260 + spin_lock_irqsave(&ps->lock, flags); 261 + if (!list_empty(&ps->async_completed)) { 262 + as = list_entry(ps->async_completed.next, struct async, 263 + asynclist); 264 + list_del_init(&as->asynclist); 265 + } 266 + spin_unlock_irqrestore(&ps->lock, flags); 267 + return as; 269 268 } 270 269 271 - static inline struct async *async_getpending(struct dev_state *ps, void __user *userurb) 270 + static inline struct async *async_getpending(struct dev_state *ps, 271 + void __user *userurb) 272 272 { 273 - unsigned long flags; 274 - struct async *as; 273 + unsigned long flags; 274 + struct async *as; 275 275 276 - spin_lock_irqsave(&ps->lock, flags); 276 + spin_lock_irqsave(&ps->lock, flags); 277 277 list_for_each_entry(as, &ps->async_pending, asynclist) 278 278 if (as->userurb == userurb) { 279 279 list_del_init(&as->asynclist); 280 280 spin_unlock_irqrestore(&ps->lock, flags); 281 281 return as; 282 282 } 283 - spin_unlock_irqrestore(&ps->lock, flags); 284 - return NULL; 283 + spin_unlock_irqrestore(&ps->lock, flags); 284 + return NULL; 285 285 } 286 286 287 287 static void snoop_urb(struct urb *urb, void __user *userurb) ··· 302 298 dev_info(&urb->dev->dev, "actual_length=%d\n", urb->actual_length); 303 299 dev_info(&urb->dev->dev, "data: "); 304 300 for (j = 0; j < urb->transfer_buffer_length; ++j) 305 - printk ("%02x ", data[j]); 301 + printk("%02x ", data[j]); 306 302 printk("\n"); 307 303 } 308 304 309 305 static void async_completed(struct urb *urb) 310 306 { 311 - struct async *as = urb->context; 312 - struct dev_state *ps = as->ps; 307 + struct async *as = urb->context; 308 + struct dev_state *ps = as->ps; 313 309 struct siginfo sinfo; 314 310 315 - spin_lock(&ps->lock); 316 - list_move_tail(&as->asynclist, &ps->async_completed); 317 - spin_unlock(&ps->lock); 311 + spin_lock(&ps->lock); 312 + list_move_tail(&as->asynclist, &ps->async_completed); 313 + spin_unlock(&ps->lock); 318 314 as->status = urb->status; 319 315 if (as->signr) { 320 316 sinfo.si_signo = as->signr; ··· 329 325 wake_up(&ps->wait); 330 326 } 331 327 332 - static void destroy_async (struct dev_state *ps, struct list_head *list) 328 + static void destroy_async(struct dev_state *ps, struct list_head *list) 333 329 { 334 330 struct async *as; 335 331 unsigned long flags; ··· 352 348 } 353 349 } 354 350 355 - static void destroy_async_on_interface (struct dev_state *ps, unsigned int ifnum) 351 + static void destroy_async_on_interface(struct dev_state *ps, 352 + unsigned int ifnum) 356 353 { 357 354 struct list_head *p, *q, hitlist; 358 355 unsigned long flags; ··· 369 364 370 365 static inline void destroy_all_async(struct dev_state *ps) 371 366 { 372 - destroy_async(ps, &ps->async_pending); 367 + destroy_async(ps, &ps->async_pending); 373 368 } 374 369 375 370 /* ··· 378 373 * they're also undone when devices disconnect. 379 374 */ 380 375 381 - static int driver_probe (struct usb_interface *intf, 382 - const struct usb_device_id *id) 376 + static int driver_probe(struct usb_interface *intf, 377 + const struct usb_device_id *id) 383 378 { 384 379 return -ENODEV; 385 380 } 386 381 387 382 static void driver_disconnect(struct usb_interface *intf) 388 383 { 389 - struct dev_state *ps = usb_get_intfdata (intf); 384 + struct dev_state *ps = usb_get_intfdata(intf); 390 385 unsigned int ifnum = intf->altsetting->desc.bInterfaceNumber; 391 386 392 387 if (!ps) ··· 401 396 else 402 397 warn("interface number %u out of range", ifnum); 403 398 404 - usb_set_intfdata (intf, NULL); 399 + usb_set_intfdata(intf, NULL); 405 400 406 401 /* force async requests to complete */ 407 402 destroy_async_on_interface(ps, ifnum); 403 + } 404 + 405 + /* The following routines are merely placeholders. There is no way 406 + * to inform a user task about suspend or resumes. 407 + */ 408 + static int driver_suspend(struct usb_interface *intf, pm_message_t msg) 409 + { 410 + return 0; 411 + } 412 + 413 + static int driver_resume(struct usb_interface *intf) 414 + { 415 + return 0; 408 416 } 409 417 410 418 struct usb_driver usbfs_driver = { 411 419 .name = "usbfs", 412 420 .probe = driver_probe, 413 421 .disconnect = driver_disconnect, 422 + .suspend = driver_suspend, 423 + .resume = driver_resume, 414 424 }; 415 425 416 426 static int claimintf(struct dev_state *ps, unsigned int ifnum) ··· 479 459 if (test_bit(ifnum, &ps->ifclaimed)) 480 460 return 0; 481 461 /* if not yet claimed, claim it for the driver */ 482 - dev_warn(&ps->dev->dev, "usbfs: process %d (%s) did not claim interface %u before use\n", 483 - task_pid_nr(current), current->comm, ifnum); 462 + dev_warn(&ps->dev->dev, "usbfs: process %d (%s) did not claim " 463 + "interface %u before use\n", task_pid_nr(current), 464 + current->comm, ifnum); 484 465 return claimintf(ps, ifnum); 485 466 } 486 467 487 468 static int findintfep(struct usb_device *dev, unsigned int ep) 488 469 { 489 470 unsigned int i, j, e; 490 - struct usb_interface *intf; 471 + struct usb_interface *intf; 491 472 struct usb_host_interface *alts; 492 473 struct usb_endpoint_descriptor *endpt; 493 474 ··· 499 478 for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { 500 479 intf = dev->actconfig->interface[i]; 501 480 for (j = 0; j < intf->num_altsetting; j++) { 502 - alts = &intf->altsetting[j]; 481 + alts = &intf->altsetting[j]; 503 482 for (e = 0; e < alts->desc.bNumEndpoints; e++) { 504 483 endpt = &alts->endpoint[e].desc; 505 484 if (endpt->bEndpointAddress == ep) ··· 507 486 } 508 487 } 509 488 } 510 - return -ENOENT; 489 + return -ENOENT; 511 490 } 512 491 513 - static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype, unsigned int index) 492 + static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype, 493 + unsigned int index) 514 494 { 515 495 int ret = 0; 516 496 ··· 524 502 index &= 0xff; 525 503 switch (requesttype & USB_RECIP_MASK) { 526 504 case USB_RECIP_ENDPOINT: 527 - if ((ret = findintfep(ps->dev, index)) >= 0) 505 + ret = findintfep(ps->dev, index); 506 + if (ret >= 0) 528 507 ret = checkintf(ps, ret); 529 508 break; 530 509 ··· 569 546 mutex_lock(&usbfs_mutex); 570 547 571 548 ret = -ENOMEM; 572 - if (!(ps = kmalloc(sizeof(struct dev_state), GFP_KERNEL))) 549 + ps = kmalloc(sizeof(struct dev_state), GFP_KERNEL); 550 + if (!ps) 573 551 goto out; 574 552 575 553 ret = -ENOENT; ··· 651 627 652 628 if (copy_from_user(&ctrl, arg, sizeof(ctrl))) 653 629 return -EFAULT; 654 - if ((ret = check_ctrlrecip(ps, ctrl.bRequestType, ctrl.wIndex))) 630 + ret = check_ctrlrecip(ps, ctrl.bRequestType, ctrl.wIndex); 631 + if (ret) 655 632 return ret; 656 633 if (ctrl.wLength > PAGE_SIZE) 657 634 return -EINVAL; 658 - if (!(tbuf = (unsigned char *)__get_free_page(GFP_KERNEL))) 635 + tbuf = (unsigned char *)__get_free_page(GFP_KERNEL); 636 + if (!tbuf) 659 637 return -ENOMEM; 660 638 tmo = ctrl.timeout; 661 639 if (ctrl.bRequestType & 0x80) { 662 - if (ctrl.wLength && !access_ok(VERIFY_WRITE, ctrl.data, ctrl.wLength)) { 640 + if (ctrl.wLength && !access_ok(VERIFY_WRITE, ctrl.data, 641 + ctrl.wLength)) { 663 642 free_page((unsigned long)tbuf); 664 643 return -EINVAL; 665 644 } ··· 673 646 ctrl.wIndex, ctrl.wLength); 674 647 675 648 usb_unlock_device(dev); 676 - i = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), ctrl.bRequest, ctrl.bRequestType, 677 - ctrl.wValue, ctrl.wIndex, tbuf, ctrl.wLength, tmo); 649 + i = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), ctrl.bRequest, 650 + ctrl.bRequestType, ctrl.wValue, ctrl.wIndex, 651 + tbuf, ctrl.wLength, tmo); 678 652 usb_lock_device(dev); 679 653 if ((i > 0) && ctrl.wLength) { 680 654 if (usbfs_snoop) { 681 655 dev_info(&dev->dev, "control read: data "); 682 656 for (j = 0; j < i; ++j) 683 - printk("%02x ", (unsigned char)(tbuf)[j]); 657 + printk("%02x ", (u8)(tbuf)[j]); 684 658 printk("\n"); 685 659 } 686 660 if (copy_to_user(ctrl.data, tbuf, i)) { ··· 708 680 printk("\n"); 709 681 } 710 682 usb_unlock_device(dev); 711 - i = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), ctrl.bRequest, ctrl.bRequestType, 712 - ctrl.wValue, ctrl.wIndex, tbuf, ctrl.wLength, tmo); 683 + i = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), ctrl.bRequest, 684 + ctrl.bRequestType, ctrl.wValue, ctrl.wIndex, 685 + tbuf, ctrl.wLength, tmo); 713 686 usb_lock_device(dev); 714 687 } 715 688 free_page((unsigned long)tbuf); 716 - if (i<0 && i != -EPIPE) { 689 + if (i < 0 && i != -EPIPE) { 717 690 dev_printk(KERN_DEBUG, &dev->dev, "usbfs: USBDEVFS_CONTROL " 718 691 "failed cmd %s rqt %u rq %u len %u ret %d\n", 719 692 current->comm, ctrl.bRequestType, ctrl.bRequest, ··· 734 705 735 706 if (copy_from_user(&bulk, arg, sizeof(bulk))) 736 707 return -EFAULT; 737 - if ((ret = findintfep(ps->dev, bulk.ep)) < 0) 708 + ret = findintfep(ps->dev, bulk.ep); 709 + if (ret < 0) 738 710 return ret; 739 - if ((ret = checkintf(ps, ret))) 711 + ret = checkintf(ps, ret); 712 + if (ret) 740 713 return ret; 741 714 if (bulk.ep & USB_DIR_IN) 742 715 pipe = usb_rcvbulkpipe(dev, bulk.ep & 0x7f); ··· 766 735 if (usbfs_snoop) { 767 736 dev_info(&dev->dev, "bulk read: data "); 768 737 for (j = 0; j < len2; ++j) 769 - printk("%02x ", (unsigned char)(tbuf)[j]); 738 + printk("%02x ", (u8)(tbuf)[j]); 770 739 printk("\n"); 771 740 } 772 741 if (copy_to_user(bulk.data, tbuf, len2)) { ··· 806 775 807 776 if (get_user(ep, (unsigned int __user *)arg)) 808 777 return -EFAULT; 809 - if ((ret = findintfep(ps->dev, ep)) < 0) 778 + ret = findintfep(ps->dev, ep); 779 + if (ret < 0) 810 780 return ret; 811 - if ((ret = checkintf(ps, ret))) 781 + ret = checkintf(ps, ret); 782 + if (ret) 812 783 return ret; 813 784 usb_settoggle(ps->dev, ep & 0xf, !(ep & USB_DIR_IN), 0); 814 785 return 0; ··· 824 791 825 792 if (get_user(ep, (unsigned int __user *)arg)) 826 793 return -EFAULT; 827 - if ((ret = findintfep(ps->dev, ep)) < 0) 794 + ret = findintfep(ps->dev, ep); 795 + if (ret < 0) 828 796 return ret; 829 - if ((ret = checkintf(ps, ret))) 797 + ret = checkintf(ps, ret); 798 + if (ret) 830 799 return ret; 831 800 if (ep & USB_DIR_IN) 832 - pipe = usb_rcvbulkpipe(ps->dev, ep & 0x7f); 833 - else 834 - pipe = usb_sndbulkpipe(ps->dev, ep & 0x7f); 801 + pipe = usb_rcvbulkpipe(ps->dev, ep & 0x7f); 802 + else 803 + pipe = usb_sndbulkpipe(ps->dev, ep & 0x7f); 835 804 836 805 return usb_clear_halt(ps->dev, pipe); 837 806 } 838 - 839 807 840 808 static int proc_getdriver(struct dev_state *ps, void __user *arg) 841 809 { ··· 890 856 { 891 857 int u; 892 858 int status = 0; 893 - struct usb_host_config *actconfig; 859 + struct usb_host_config *actconfig; 894 860 895 861 if (get_user(u, (int __user *)arg)) 896 862 return -EFAULT; 897 863 898 - actconfig = ps->dev->actconfig; 899 - 900 - /* Don't touch the device if any interfaces are claimed. 901 - * It could interfere with other drivers' operations, and if 864 + actconfig = ps->dev->actconfig; 865 + 866 + /* Don't touch the device if any interfaces are claimed. 867 + * It could interfere with other drivers' operations, and if 902 868 * an interface is claimed by usbfs it could easily deadlock. 903 869 */ 904 - if (actconfig) { 905 - int i; 906 - 907 - for (i = 0; i < actconfig->desc.bNumInterfaces; ++i) { 908 - if (usb_interface_claimed(actconfig->interface[i])) { 909 - dev_warn (&ps->dev->dev, 870 + if (actconfig) { 871 + int i; 872 + 873 + for (i = 0; i < actconfig->desc.bNumInterfaces; ++i) { 874 + if (usb_interface_claimed(actconfig->interface[i])) { 875 + dev_warn(&ps->dev->dev, 910 876 "usbfs: interface %d claimed by %s " 911 877 "while '%s' sets config #%d\n", 912 878 actconfig->interface[i] ··· 915 881 actconfig->interface[i] 916 882 ->dev.driver->name, 917 883 current->comm, u); 918 - status = -EBUSY; 884 + status = -EBUSY; 919 885 break; 920 886 } 921 - } 922 - } 887 + } 888 + } 923 889 924 890 /* SET_CONFIGURATION is often abused as a "cheap" driver reset, 925 891 * so avoid usb_set_configuration()'s kick to sysfs ··· 935 901 } 936 902 937 903 static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, 938 - struct usbdevfs_iso_packet_desc __user *iso_frame_desc, 939 - void __user *arg) 904 + struct usbdevfs_iso_packet_desc __user *iso_frame_desc, 905 + void __user *arg) 940 906 { 941 907 struct usbdevfs_iso_packet_desc *isopkt = NULL; 942 908 struct usb_host_endpoint *ep; ··· 951 917 return -EINVAL; 952 918 if (!uurb->buffer) 953 919 return -EINVAL; 954 - if (uurb->signr != 0 && (uurb->signr < SIGRTMIN || uurb->signr > SIGRTMAX)) 920 + if (uurb->signr != 0 && (uurb->signr < SIGRTMIN || 921 + uurb->signr > SIGRTMAX)) 955 922 return -EINVAL; 956 - if (!(uurb->type == USBDEVFS_URB_TYPE_CONTROL && (uurb->endpoint & ~USB_ENDPOINT_DIR_MASK) == 0)) { 957 - if ((ifnum = findintfep(ps->dev, uurb->endpoint)) < 0) 923 + if (!(uurb->type == USBDEVFS_URB_TYPE_CONTROL && 924 + (uurb->endpoint & ~USB_ENDPOINT_DIR_MASK) == 0)) { 925 + ifnum = findintfep(ps->dev, uurb->endpoint); 926 + if (ifnum < 0) 958 927 return ifnum; 959 - if ((ret = checkintf(ps, ifnum))) 928 + ret = checkintf(ps, ifnum); 929 + if (ret) 960 930 return ret; 961 931 } 962 932 if ((uurb->endpoint & USB_ENDPOINT_DIR_MASK) != 0) { ··· 976 938 case USBDEVFS_URB_TYPE_CONTROL: 977 939 if (!usb_endpoint_xfer_control(&ep->desc)) 978 940 return -EINVAL; 979 - /* min 8 byte setup packet, max 8 byte setup plus an arbitrary data stage */ 980 - if (uurb->buffer_length < 8 || uurb->buffer_length > (8 + MAX_USBFS_BUFFER_SIZE)) 941 + /* min 8 byte setup packet, 942 + * max 8 byte setup plus an arbitrary data stage */ 943 + if (uurb->buffer_length < 8 || 944 + uurb->buffer_length > (8 + MAX_USBFS_BUFFER_SIZE)) 981 945 return -EINVAL; 982 - if (!(dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL))) 946 + dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL); 947 + if (!dr) 983 948 return -ENOMEM; 984 949 if (copy_from_user(dr, uurb->buffer, 8)) { 985 950 kfree(dr); ··· 992 951 kfree(dr); 993 952 return -EINVAL; 994 953 } 995 - if ((ret = check_ctrlrecip(ps, dr->bRequestType, le16_to_cpup(&dr->wIndex)))) { 954 + ret = check_ctrlrecip(ps, dr->bRequestType, 955 + le16_to_cpup(&dr->wIndex)); 956 + if (ret) { 996 957 kfree(dr); 997 958 return ret; 998 959 } ··· 1040 997 1041 998 case USBDEVFS_URB_TYPE_ISO: 1042 999 /* arbitrary limit */ 1043 - if (uurb->number_of_packets < 1 || uurb->number_of_packets > 128) 1000 + if (uurb->number_of_packets < 1 || 1001 + uurb->number_of_packets > 128) 1044 1002 return -EINVAL; 1045 1003 if (!usb_endpoint_xfer_isoc(&ep->desc)) 1046 1004 return -EINVAL; 1047 - isofrmlen = sizeof(struct usbdevfs_iso_packet_desc) * uurb->number_of_packets; 1005 + isofrmlen = sizeof(struct usbdevfs_iso_packet_desc) * 1006 + uurb->number_of_packets; 1048 1007 if (!(isopkt = kmalloc(isofrmlen, GFP_KERNEL))) 1049 1008 return -ENOMEM; 1050 1009 if (copy_from_user(isopkt, iso_frame_desc, isofrmlen)) { ··· 1054 1009 return -EFAULT; 1055 1010 } 1056 1011 for (totlen = u = 0; u < uurb->number_of_packets; u++) { 1057 - /* arbitrary limit, sufficient for USB 2.0 high-bandwidth iso */ 1012 + /* arbitrary limit, 1013 + * sufficient for USB 2.0 high-bandwidth iso */ 1058 1014 if (isopkt[u].length > 8192) { 1059 1015 kfree(isopkt); 1060 1016 return -EINVAL; ··· 1085 1039 default: 1086 1040 return -EINVAL; 1087 1041 } 1088 - if (!(as = alloc_async(uurb->number_of_packets))) { 1042 + as = alloc_async(uurb->number_of_packets); 1043 + if (!as) { 1089 1044 kfree(isopkt); 1090 1045 kfree(dr); 1091 1046 return -ENOMEM; 1092 1047 } 1093 - if (!(as->urb->transfer_buffer = kmalloc(uurb->buffer_length, GFP_KERNEL))) { 1048 + as->urb->transfer_buffer = kmalloc(uurb->buffer_length, GFP_KERNEL); 1049 + if (!as->urb->transfer_buffer) { 1094 1050 kfree(isopkt); 1095 1051 kfree(dr); 1096 1052 free_async(as); 1097 1053 return -ENOMEM; 1098 1054 } 1099 - as->urb->dev = ps->dev; 1100 - as->urb->pipe = (uurb->type << 30) | 1055 + as->urb->dev = ps->dev; 1056 + as->urb->pipe = (uurb->type << 30) | 1101 1057 __create_pipe(ps->dev, uurb->endpoint & 0xf) | 1102 1058 (uurb->endpoint & USB_DIR_IN); 1103 - as->urb->transfer_flags = uurb->flags | 1059 + as->urb->transfer_flags = uurb->flags | 1104 1060 (is_in ? URB_DIR_IN : URB_DIR_OUT); 1105 1061 as->urb->transfer_buffer_length = uurb->buffer_length; 1106 - as->urb->setup_packet = (unsigned char*)dr; 1062 + as->urb->setup_packet = (unsigned char *)dr; 1107 1063 as->urb->start_frame = uurb->start_frame; 1108 1064 as->urb->number_of_packets = uurb->number_of_packets; 1109 1065 if (uurb->type == USBDEVFS_URB_TYPE_ISO || ··· 1113 1065 as->urb->interval = 1 << min(15, ep->desc.bInterval - 1); 1114 1066 else 1115 1067 as->urb->interval = ep->desc.bInterval; 1116 - as->urb->context = as; 1117 - as->urb->complete = async_completed; 1068 + as->urb->context = as; 1069 + as->urb->complete = async_completed; 1118 1070 for (totlen = u = 0; u < uurb->number_of_packets; u++) { 1119 1071 as->urb->iso_frame_desc[u].offset = totlen; 1120 1072 as->urb->iso_frame_desc[u].length = isopkt[u].length; ··· 1122 1074 } 1123 1075 kfree(isopkt); 1124 1076 as->ps = ps; 1125 - as->userurb = arg; 1077 + as->userurb = arg; 1126 1078 if (uurb->endpoint & USB_DIR_IN) 1127 1079 as->userbuffer = uurb->buffer; 1128 1080 else ··· 1141 1093 } 1142 1094 } 1143 1095 snoop_urb(as->urb, as->userurb); 1144 - async_newpending(as); 1145 - if ((ret = usb_submit_urb(as->urb, GFP_KERNEL))) { 1146 - dev_printk(KERN_DEBUG, &ps->dev->dev, "usbfs: usb_submit_urb returned %d\n", ret); 1147 - async_removepending(as); 1148 - free_async(as); 1149 - return ret; 1150 - } 1151 - return 0; 1096 + async_newpending(as); 1097 + if ((ret = usb_submit_urb(as->urb, GFP_KERNEL))) { 1098 + dev_printk(KERN_DEBUG, &ps->dev->dev, 1099 + "usbfs: usb_submit_urb returned %d\n", ret); 1100 + async_removepending(as); 1101 + free_async(as); 1102 + return ret; 1103 + } 1104 + return 0; 1152 1105 } 1153 1106 1154 1107 static int proc_submiturb(struct dev_state *ps, void __user *arg) ··· 1159 1110 if (copy_from_user(&uurb, arg, sizeof(uurb))) 1160 1111 return -EFAULT; 1161 1112 1162 - return proc_do_submiturb(ps, &uurb, (((struct usbdevfs_urb __user *)arg)->iso_frame_desc), arg); 1113 + return proc_do_submiturb(ps, &uurb, 1114 + (((struct usbdevfs_urb __user *)arg)->iso_frame_desc), 1115 + arg); 1163 1116 } 1164 1117 1165 1118 static int proc_unlinkurb(struct dev_state *ps, void __user *arg) ··· 1183 1132 unsigned int i; 1184 1133 1185 1134 if (as->userbuffer) 1186 - if (copy_to_user(as->userbuffer, urb->transfer_buffer, urb->transfer_buffer_length)) 1135 + if (copy_to_user(as->userbuffer, urb->transfer_buffer, 1136 + urb->transfer_buffer_length)) 1187 1137 return -EFAULT; 1188 1138 if (put_user(as->status, &userurb->status)) 1189 1139 return -EFAULT; ··· 1211 1159 return 0; 1212 1160 } 1213 1161 1214 - static struct async* reap_as(struct dev_state *ps) 1162 + static struct async *reap_as(struct dev_state *ps) 1215 1163 { 1216 - DECLARE_WAITQUEUE(wait, current); 1164 + DECLARE_WAITQUEUE(wait, current); 1217 1165 struct async *as = NULL; 1218 1166 struct usb_device *dev = ps->dev; 1219 1167 1220 1168 add_wait_queue(&ps->wait, &wait); 1221 1169 for (;;) { 1222 1170 __set_current_state(TASK_INTERRUPTIBLE); 1223 - if ((as = async_getcompleted(ps))) 1171 + as = async_getcompleted(ps); 1172 + if (as) 1224 1173 break; 1225 1174 if (signal_pending(current)) 1226 1175 break; ··· 1285 1232 { 1286 1233 struct usbdevfs_urb uurb; 1287 1234 1288 - if (get_urb32(&uurb,(struct usbdevfs_urb32 __user *)arg)) 1235 + if (get_urb32(&uurb, (struct usbdevfs_urb32 __user *)arg)) 1289 1236 return -EFAULT; 1290 1237 1291 - return proc_do_submiturb(ps, &uurb, ((struct usbdevfs_urb32 __user *)arg)->iso_frame_desc, arg); 1238 + return proc_do_submiturb(ps, &uurb, 1239 + ((struct usbdevfs_urb32 __user *)arg)->iso_frame_desc, 1240 + arg); 1292 1241 } 1293 1242 1294 1243 static int processcompl_compat(struct async *as, void __user * __user *arg) ··· 1301 1246 unsigned int i; 1302 1247 1303 1248 if (as->userbuffer) 1304 - if (copy_to_user(as->userbuffer, urb->transfer_buffer, urb->transfer_buffer_length)) 1249 + if (copy_to_user(as->userbuffer, urb->transfer_buffer, 1250 + urb->transfer_buffer_length)) 1305 1251 return -EFAULT; 1306 1252 if (put_user(as->status, &userurb->status)) 1307 1253 return -EFAULT; ··· 1393 1337 struct usb_driver *driver = NULL; 1394 1338 1395 1339 /* alloc buffer */ 1396 - if ((size = _IOC_SIZE (ctl->ioctl_code)) > 0) { 1397 - if ((buf = kmalloc (size, GFP_KERNEL)) == NULL) 1340 + if ((size = _IOC_SIZE(ctl->ioctl_code)) > 0) { 1341 + if ((buf = kmalloc(size, GFP_KERNEL)) == NULL) 1398 1342 return -ENOMEM; 1399 1343 if ((_IOC_DIR(ctl->ioctl_code) & _IOC_WRITE)) { 1400 - if (copy_from_user (buf, ctl->data, size)) { 1344 + if (copy_from_user(buf, ctl->data, size)) { 1401 1345 kfree(buf); 1402 1346 return -EFAULT; 1403 1347 } 1404 1348 } else { 1405 - memset (buf, 0, size); 1349 + memset(buf, 0, size); 1406 1350 } 1407 1351 } 1408 1352 ··· 1413 1357 1414 1358 if (ps->dev->state != USB_STATE_CONFIGURED) 1415 1359 retval = -EHOSTUNREACH; 1416 - else if (!(intf = usb_ifnum_to_if (ps->dev, ctl->ifno))) 1417 - retval = -EINVAL; 1360 + else if (!(intf = usb_ifnum_to_if(ps->dev, ctl->ifno))) 1361 + retval = -EINVAL; 1418 1362 else switch (ctl->ioctl_code) { 1419 1363 1420 1364 /* disconnect kernel driver from interface */ 1421 1365 case USBDEVFS_DISCONNECT: 1422 1366 if (intf->dev.driver) { 1423 1367 driver = to_usb_driver(intf->dev.driver); 1424 - dev_dbg (&intf->dev, "disconnect by usbfs\n"); 1368 + dev_dbg(&intf->dev, "disconnect by usbfs\n"); 1425 1369 usb_driver_release_interface(driver, intf); 1426 1370 } else 1427 1371 retval = -ENODATA; ··· 1429 1373 1430 1374 /* let kernel drivers try to (re)bind to the interface */ 1431 1375 case USBDEVFS_CONNECT: 1432 - usb_unlock_device(ps->dev); 1433 - retval = bus_rescan_devices(intf->dev.bus); 1434 - usb_lock_device(ps->dev); 1376 + if (!intf->dev.driver) 1377 + retval = device_attach(&intf->dev); 1378 + else 1379 + retval = -EBUSY; 1435 1380 break; 1436 1381 1437 1382 /* talk directly to the interface's driver */ ··· 1442 1385 if (driver == NULL || driver->ioctl == NULL) { 1443 1386 retval = -ENOTTY; 1444 1387 } else { 1445 - retval = driver->ioctl (intf, ctl->ioctl_code, buf); 1388 + retval = driver->ioctl(intf, ctl->ioctl_code, buf); 1446 1389 if (retval == -ENOIOCTLCMD) 1447 1390 retval = -ENOTTY; 1448 1391 } ··· 1450 1393 1451 1394 /* cleanup and return */ 1452 1395 if (retval >= 0 1453 - && (_IOC_DIR (ctl->ioctl_code) & _IOC_READ) != 0 1396 + && (_IOC_DIR(ctl->ioctl_code) & _IOC_READ) != 0 1454 1397 && size > 0 1455 - && copy_to_user (ctl->data, buf, size) != 0) 1398 + && copy_to_user(ctl->data, buf, size) != 0) 1456 1399 retval = -EFAULT; 1457 1400 1458 1401 kfree(buf); ··· 1463 1406 { 1464 1407 struct usbdevfs_ioctl ctrl; 1465 1408 1466 - if (copy_from_user(&ctrl, arg, sizeof (ctrl))) 1409 + if (copy_from_user(&ctrl, arg, sizeof(ctrl))) 1467 1410 return -EFAULT; 1468 1411 return proc_ioctl(ps, &ctrl); 1469 1412 } ··· 1491 1434 * are assuming that somehow the configuration has been prevented from 1492 1435 * changing. But there's no mechanism to ensure that... 1493 1436 */ 1494 - static int usbdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) 1437 + static int usbdev_ioctl(struct inode *inode, struct file *file, 1438 + unsigned int cmd, unsigned long arg) 1495 1439 { 1496 1440 struct dev_state *ps = file->private_data; 1497 1441 struct usb_device *dev = ps->dev; ··· 1635 1577 } 1636 1578 1637 1579 /* No kernel lock - fine */ 1638 - static unsigned int usbdev_poll(struct file *file, struct poll_table_struct *wait) 1580 + static unsigned int usbdev_poll(struct file *file, 1581 + struct poll_table_struct *wait) 1639 1582 { 1640 1583 struct dev_state *ps = file->private_data; 1641 1584 unsigned int mask = 0; ··· 1707 1648 int retval; 1708 1649 1709 1650 retval = register_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX, 1710 - "usb_device"); 1651 + "usb_device"); 1711 1652 if (retval) { 1712 1653 err("unable to register minors for usb_device"); 1713 1654 goto out;
+23 -21
drivers/usb/core/driver.c
··· 202 202 intf = to_usb_interface(dev); 203 203 udev = interface_to_usbdev(intf); 204 204 205 - if (udev->authorized == 0) { 206 - dev_err(&intf->dev, "Device is not authorized for usage\n"); 207 - return -ENODEV; 208 - } 205 + if (udev->authorized == 0) { 206 + dev_err(&intf->dev, "Device is not authorized for usage\n"); 207 + return -ENODEV; 208 + } 209 209 210 210 id = usb_match_id(intf, driver->id_table); 211 211 if (!id) ··· 299 299 * lock. 300 300 */ 301 301 int usb_driver_claim_interface(struct usb_driver *driver, 302 - struct usb_interface *iface, void* priv) 302 + struct usb_interface *iface, void *priv) 303 303 { 304 304 struct device *dev = &iface->dev; 305 305 struct usb_device *udev = interface_to_usbdev(iface); ··· 325 325 326 326 return retval; 327 327 } 328 - EXPORT_SYMBOL(usb_driver_claim_interface); 328 + EXPORT_SYMBOL_GPL(usb_driver_claim_interface); 329 329 330 330 /** 331 331 * usb_driver_release_interface - unbind a driver from an interface ··· 370 370 iface->needs_remote_wakeup = 0; 371 371 usb_pm_unlock(udev); 372 372 } 373 - EXPORT_SYMBOL(usb_driver_release_interface); 373 + EXPORT_SYMBOL_GPL(usb_driver_release_interface); 374 374 375 375 /* returns 0 if no match, 1 if match */ 376 376 int usb_match_device(struct usb_device *dev, const struct usb_device_id *id) ··· 398 398 return 0; 399 399 400 400 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) && 401 - (id->bDeviceSubClass!= dev->descriptor.bDeviceSubClass)) 401 + (id->bDeviceSubClass != dev->descriptor.bDeviceSubClass)) 402 402 return 0; 403 403 404 404 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) && ··· 534 534 id->driver_info is the way to create an entry that 535 535 indicates that the driver want to examine every 536 536 device and interface. */ 537 - for (; id->idVendor || id->bDeviceClass || id->bInterfaceClass || 538 - id->driver_info; id++) { 537 + for (; id->idVendor || id->idProduct || id->bDeviceClass || 538 + id->bInterfaceClass || id->driver_info; id++) { 539 539 if (usb_match_one_id(interface, id)) 540 540 return id; 541 541 } 542 542 543 543 return NULL; 544 544 } 545 - EXPORT_SYMBOL_GPL_FUTURE(usb_match_id); 545 + EXPORT_SYMBOL_GPL(usb_match_id); 546 546 547 547 static int usb_device_match(struct device *dev, struct device_driver *drv) 548 548 { ··· 586 586 struct usb_device *usb_dev; 587 587 588 588 /* driver is often null here; dev_dbg() would oops */ 589 - pr_debug ("usb %s: uevent\n", dev->bus_id); 589 + pr_debug("usb %s: uevent\n", dev->bus_id); 590 590 591 591 if (is_usb_device(dev)) 592 592 usb_dev = to_usb_device(dev); ··· 596 596 } 597 597 598 598 if (usb_dev->devnum < 0) { 599 - pr_debug ("usb %s: already deleted?\n", dev->bus_id); 599 + pr_debug("usb %s: already deleted?\n", dev->bus_id); 600 600 return -ENODEV; 601 601 } 602 602 if (!usb_dev->bus) { 603 - pr_debug ("usb %s: bus removed?\n", dev->bus_id); 603 + pr_debug("usb %s: bus removed?\n", dev->bus_id); 604 604 return -ENODEV; 605 605 } 606 606 ··· 745 745 746 746 return retval; 747 747 } 748 - EXPORT_SYMBOL_GPL_FUTURE(usb_register_driver); 748 + EXPORT_SYMBOL_GPL(usb_register_driver); 749 749 750 750 /** 751 751 * usb_deregister - unregister a USB interface driver ··· 769 769 770 770 usbfs_update_special(); 771 771 } 772 - EXPORT_SYMBOL_GPL_FUTURE(usb_deregister); 772 + EXPORT_SYMBOL_GPL(usb_deregister); 773 773 774 774 #ifdef CONFIG_PM 775 775 ··· 854 854 dev_err(&intf->dev, "%s error %d\n", 855 855 "suspend", status); 856 856 } else { 857 - // FIXME else if there's no suspend method, disconnect... 858 - // Not possible if auto_pm is set... 857 + /* 858 + * FIXME else if there's no suspend method, disconnect... 859 + * Not possible if auto_pm is set... 860 + */ 859 861 dev_warn(&intf->dev, "no suspend for driver %s?\n", 860 862 driver->name); 861 863 mark_quiesced(intf); ··· 896 894 dev_err(&intf->dev, "%s error %d\n", 897 895 "reset_resume", status); 898 896 } else { 899 - // status = -EOPNOTSUPP; 897 + /* status = -EOPNOTSUPP; */ 900 898 dev_warn(&intf->dev, "no %s for driver %s?\n", 901 899 "reset_resume", driver->name); 902 900 } ··· 907 905 dev_err(&intf->dev, "%s error %d\n", 908 906 "resume", status); 909 907 } else { 910 - // status = -EOPNOTSUPP; 908 + /* status = -EOPNOTSUPP; */ 911 909 dev_warn(&intf->dev, "no %s for driver %s?\n", 912 910 "resume", driver->name); 913 911 } ··· 1177 1175 * so if a root hub's controller is suspended 1178 1176 * then we're stuck. */ 1179 1177 status = usb_resume_device(udev); 1180 - } 1178 + } 1181 1179 } else { 1182 1180 1183 1181 /* Needed for setting udev->dev.power.power_state.event,
+2 -2
drivers/usb/core/file.c
··· 204 204 exit: 205 205 return retval; 206 206 } 207 - EXPORT_SYMBOL(usb_register_dev); 207 + EXPORT_SYMBOL_GPL(usb_register_dev); 208 208 209 209 /** 210 210 * usb_deregister_dev - deregister a USB device's dynamic minor. ··· 245 245 intf->minor = -1; 246 246 destroy_usb_class(); 247 247 } 248 - EXPORT_SYMBOL(usb_deregister_dev); 248 + EXPORT_SYMBOL_GPL(usb_deregister_dev);
+78 -67
drivers/usb/core/hcd-pci.c
··· 1 1 /* 2 2 * (C) Copyright David Brownell 2000-2002 3 - * 3 + * 4 4 * This program is free software; you can redistribute it and/or modify it 5 5 * under the terms of the GNU General Public License as published by the 6 6 * Free Software Foundation; either version 2 of the License, or (at your ··· 55 55 * 56 56 * Store this function in the HCD's struct pci_driver as probe(). 57 57 */ 58 - int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id) 58 + int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) 59 59 { 60 60 struct hc_driver *driver; 61 61 struct usb_hcd *hcd; ··· 64 64 if (usb_disabled()) 65 65 return -ENODEV; 66 66 67 - if (!id || !(driver = (struct hc_driver *) id->driver_data)) 67 + if (!id) 68 + return -EINVAL; 69 + driver = (struct hc_driver *)id->driver_data; 70 + if (!driver) 68 71 return -EINVAL; 69 72 70 - if (pci_enable_device (dev) < 0) 73 + if (pci_enable_device(dev) < 0) 71 74 return -ENODEV; 72 75 dev->current_state = PCI_D0; 73 76 dev->dev.power.power_state = PMSG_ON; 74 - 75 - if (!dev->irq) { 76 - dev_err (&dev->dev, 77 + 78 + if (!dev->irq) { 79 + dev_err(&dev->dev, 77 80 "Found HC with no IRQ. Check BIOS/PCI %s setup!\n", 78 81 pci_name(dev)); 79 - retval = -ENODEV; 82 + retval = -ENODEV; 80 83 goto err1; 81 - } 84 + } 82 85 83 - hcd = usb_create_hcd (driver, &dev->dev, pci_name(dev)); 86 + hcd = usb_create_hcd(driver, &dev->dev, pci_name(dev)); 84 87 if (!hcd) { 85 88 retval = -ENOMEM; 86 89 goto err1; 87 90 } 88 91 89 - if (driver->flags & HCD_MEMORY) { // EHCI, OHCI 90 - hcd->rsrc_start = pci_resource_start (dev, 0); 91 - hcd->rsrc_len = pci_resource_len (dev, 0); 92 - if (!request_mem_region (hcd->rsrc_start, hcd->rsrc_len, 92 + if (driver->flags & HCD_MEMORY) { 93 + /* EHCI, OHCI */ 94 + hcd->rsrc_start = pci_resource_start(dev, 0); 95 + hcd->rsrc_len = pci_resource_len(dev, 0); 96 + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, 93 97 driver->description)) { 94 - dev_dbg (&dev->dev, "controller already in use\n"); 98 + dev_dbg(&dev->dev, "controller already in use\n"); 95 99 retval = -EBUSY; 96 100 goto err2; 97 101 } 98 - hcd->regs = ioremap_nocache (hcd->rsrc_start, hcd->rsrc_len); 102 + hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); 99 103 if (hcd->regs == NULL) { 100 - dev_dbg (&dev->dev, "error mapping memory\n"); 104 + dev_dbg(&dev->dev, "error mapping memory\n"); 101 105 retval = -EFAULT; 102 106 goto err3; 103 107 } 104 108 105 - } else { // UHCI 109 + } else { 110 + /* UHCI */ 106 111 int region; 107 112 108 113 for (region = 0; region < PCI_ROM_RESOURCE; region++) { 109 - if (!(pci_resource_flags (dev, region) & 114 + if (!(pci_resource_flags(dev, region) & 110 115 IORESOURCE_IO)) 111 116 continue; 112 117 113 - hcd->rsrc_start = pci_resource_start (dev, region); 114 - hcd->rsrc_len = pci_resource_len (dev, region); 115 - if (request_region (hcd->rsrc_start, hcd->rsrc_len, 118 + hcd->rsrc_start = pci_resource_start(dev, region); 119 + hcd->rsrc_len = pci_resource_len(dev, region); 120 + if (request_region(hcd->rsrc_start, hcd->rsrc_len, 116 121 driver->description)) 117 122 break; 118 123 } 119 124 if (region == PCI_ROM_RESOURCE) { 120 - dev_dbg (&dev->dev, "no i/o regions available\n"); 125 + dev_dbg(&dev->dev, "no i/o regions available\n"); 121 126 retval = -EBUSY; 122 127 goto err1; 123 128 } 124 129 } 125 130 126 - pci_set_master (dev); 131 + pci_set_master(dev); 127 132 128 133 retval = usb_add_hcd(hcd, dev->irq, IRQF_DISABLED | IRQF_SHARED); 129 134 if (retval != 0) ··· 137 132 138 133 err4: 139 134 if (driver->flags & HCD_MEMORY) { 140 - iounmap (hcd->regs); 135 + iounmap(hcd->regs); 141 136 err3: 142 - release_mem_region (hcd->rsrc_start, hcd->rsrc_len); 137 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 143 138 } else 144 - release_region (hcd->rsrc_start, hcd->rsrc_len); 139 + release_region(hcd->rsrc_start, hcd->rsrc_len); 145 140 err2: 146 - usb_put_hcd (hcd); 141 + usb_put_hcd(hcd); 147 142 err1: 148 - pci_disable_device (dev); 149 - dev_err (&dev->dev, "init %s fail, %d\n", pci_name(dev), retval); 143 + pci_disable_device(dev); 144 + dev_err(&dev->dev, "init %s fail, %d\n", pci_name(dev), retval); 150 145 return retval; 151 - } 152 - EXPORT_SYMBOL (usb_hcd_pci_probe); 146 + } 147 + EXPORT_SYMBOL_GPL(usb_hcd_pci_probe); 153 148 154 149 155 150 /* may be called without controller electrically present */ ··· 166 161 * 167 162 * Store this function in the HCD's struct pci_driver as remove(). 168 163 */ 169 - void usb_hcd_pci_remove (struct pci_dev *dev) 164 + void usb_hcd_pci_remove(struct pci_dev *dev) 170 165 { 171 166 struct usb_hcd *hcd; 172 167 ··· 174 169 if (!hcd) 175 170 return; 176 171 177 - usb_remove_hcd (hcd); 172 + usb_remove_hcd(hcd); 178 173 if (hcd->driver->flags & HCD_MEMORY) { 179 - iounmap (hcd->regs); 180 - release_mem_region (hcd->rsrc_start, hcd->rsrc_len); 174 + iounmap(hcd->regs); 175 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 181 176 } else { 182 - release_region (hcd->rsrc_start, hcd->rsrc_len); 177 + release_region(hcd->rsrc_start, hcd->rsrc_len); 183 178 } 184 - usb_put_hcd (hcd); 179 + usb_put_hcd(hcd); 185 180 pci_disable_device(dev); 186 181 } 187 - EXPORT_SYMBOL (usb_hcd_pci_remove); 182 + EXPORT_SYMBOL_GPL(usb_hcd_pci_remove); 188 183 189 184 190 185 #ifdef CONFIG_PM ··· 196 191 * 197 192 * Store this function in the HCD's struct pci_driver as suspend(). 198 193 */ 199 - int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message) 194 + int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t message) 200 195 { 201 196 struct usb_hcd *hcd; 202 197 int retval = 0; ··· 251 246 252 247 /* no DMA or IRQs except when HC is active */ 253 248 if (dev->current_state == PCI_D0) { 254 - pci_save_state (dev); 255 - pci_disable_device (dev); 249 + pci_save_state(dev); 250 + pci_disable_device(dev); 251 + } 252 + 253 + if (message.event == PM_EVENT_FREEZE || 254 + message.event == PM_EVENT_PRETHAW) { 255 + dev_dbg(hcd->self.controller, "--> no state change\n"); 256 + goto done; 256 257 } 257 258 258 259 if (!has_pci_pm) { 259 - dev_dbg (hcd->self.controller, "--> PCI D0/legacy\n"); 260 + dev_dbg(hcd->self.controller, "--> PCI D0/legacy\n"); 260 261 goto done; 261 262 } 262 263 ··· 271 260 * PCI_D3 (but not PCI_D1 or PCI_D2) is allowed to reset 272 261 * some device state (e.g. as part of clock reinit). 273 262 */ 274 - retval = pci_set_power_state (dev, PCI_D3hot); 263 + retval = pci_set_power_state(dev, PCI_D3hot); 275 264 suspend_report_result(pci_set_power_state, retval); 276 265 if (retval == 0) { 277 266 int wake = device_can_wakeup(&hcd->self.root_hub->dev); 278 267 279 268 wake = wake && device_may_wakeup(hcd->self.controller); 280 269 281 - dev_dbg (hcd->self.controller, "--> PCI D3%s\n", 270 + dev_dbg(hcd->self.controller, "--> PCI D3%s\n", 282 271 wake ? "/wakeup" : ""); 283 272 284 273 /* Ignore these return values. We rely on pci code to 285 274 * reject requests the hardware can't implement, rather 286 275 * than coding the same thing. 287 276 */ 288 - (void) pci_enable_wake (dev, PCI_D3hot, wake); 289 - (void) pci_enable_wake (dev, PCI_D3cold, wake); 277 + (void) pci_enable_wake(dev, PCI_D3hot, wake); 278 + (void) pci_enable_wake(dev, PCI_D3cold, wake); 290 279 } else { 291 - dev_dbg (&dev->dev, "PCI D3 suspend fail, %d\n", 280 + dev_dbg(&dev->dev, "PCI D3 suspend fail, %d\n", 292 281 retval); 293 - (void) usb_hcd_pci_resume (dev); 282 + (void) usb_hcd_pci_resume(dev); 294 283 } 295 284 296 285 } else if (hcd->state != HC_STATE_HALT) { 297 - dev_dbg (hcd->self.controller, "hcd state %d; not suspended\n", 286 + dev_dbg(hcd->self.controller, "hcd state %d; not suspended\n", 298 287 hcd->state); 299 288 WARN_ON(1); 300 289 retval = -EINVAL; ··· 309 298 if (machine_is(powermac)) { 310 299 struct device_node *of_node; 311 300 312 - of_node = pci_device_to_OF_node (dev); 301 + of_node = pci_device_to_OF_node(dev); 313 302 if (of_node) 314 303 pmac_call_feature(PMAC_FTR_USB_ENABLE, 315 304 of_node, 0, 0); ··· 319 308 320 309 return retval; 321 310 } 322 - EXPORT_SYMBOL (usb_hcd_pci_suspend); 311 + EXPORT_SYMBOL_GPL(usb_hcd_pci_suspend); 323 312 324 313 /** 325 314 * usb_hcd_pci_resume - power management resume of a PCI-based HCD ··· 327 316 * 328 317 * Store this function in the HCD's struct pci_driver as resume(). 329 318 */ 330 - int usb_hcd_pci_resume (struct pci_dev *dev) 319 + int usb_hcd_pci_resume(struct pci_dev *dev) 331 320 { 332 321 struct usb_hcd *hcd; 333 322 int retval; 334 323 335 324 hcd = pci_get_drvdata(dev); 336 325 if (hcd->state != HC_STATE_SUSPENDED) { 337 - dev_dbg (hcd->self.controller, 326 + dev_dbg(hcd->self.controller, 338 327 "can't resume, not suspended!\n"); 339 328 return 0; 340 329 } ··· 344 333 if (machine_is(powermac)) { 345 334 struct device_node *of_node; 346 335 347 - of_node = pci_device_to_OF_node (dev); 336 + of_node = pci_device_to_OF_node(dev); 348 337 if (of_node) 349 - pmac_call_feature (PMAC_FTR_USB_ENABLE, 338 + pmac_call_feature(PMAC_FTR_USB_ENABLE, 350 339 of_node, 0, 1); 351 340 } 352 341 #endif ··· 385 374 } 386 375 #endif 387 376 /* yes, ignore these results too... */ 388 - (void) pci_enable_wake (dev, dev->current_state, 0); 389 - (void) pci_enable_wake (dev, PCI_D3cold, 0); 377 + (void) pci_enable_wake(dev, dev->current_state, 0); 378 + (void) pci_enable_wake(dev, PCI_D3cold, 0); 390 379 } else { 391 380 /* Same basic cases: clean (powered/not), dirty */ 392 381 dev_dbg(hcd->self.controller, "PCI legacy resume\n"); ··· 397 386 * but that won't re-enable bus mastering. Yet pci_disable_device() 398 387 * explicitly disables bus mastering... 399 388 */ 400 - retval = pci_enable_device (dev); 389 + retval = pci_enable_device(dev); 401 390 if (retval < 0) { 402 - dev_err (hcd->self.controller, 391 + dev_err(hcd->self.controller, 403 392 "can't re-enable after resume, %d!\n", retval); 404 393 return retval; 405 394 } 406 - pci_set_master (dev); 407 - pci_restore_state (dev); 395 + pci_set_master(dev); 396 + pci_restore_state(dev); 408 397 409 398 dev->dev.power.power_state = PMSG_ON; 410 399 ··· 413 402 if (hcd->driver->resume) { 414 403 retval = hcd->driver->resume(hcd); 415 404 if (retval) { 416 - dev_err (hcd->self.controller, 405 + dev_err(hcd->self.controller, 417 406 "PCI post-resume error %d!\n", retval); 418 - usb_hc_died (hcd); 407 + usb_hc_died(hcd); 419 408 } 420 409 } 421 410 422 411 return retval; 423 412 } 424 - EXPORT_SYMBOL (usb_hcd_pci_resume); 413 + EXPORT_SYMBOL_GPL(usb_hcd_pci_resume); 425 414 426 415 #endif /* CONFIG_PM */ 427 416 ··· 429 418 * usb_hcd_pci_shutdown - shutdown host controller 430 419 * @dev: USB Host Controller being shutdown 431 420 */ 432 - void usb_hcd_pci_shutdown (struct pci_dev *dev) 421 + void usb_hcd_pci_shutdown(struct pci_dev *dev) 433 422 { 434 423 struct usb_hcd *hcd; 435 424 ··· 440 429 if (hcd->driver->shutdown) 441 430 hcd->driver->shutdown(hcd); 442 431 } 443 - EXPORT_SYMBOL (usb_hcd_pci_shutdown); 432 + EXPORT_SYMBOL_GPL(usb_hcd_pci_shutdown); 444 433
+176 -40
drivers/usb/core/hcd.c
··· 35 35 #include <linux/mutex.h> 36 36 #include <asm/irq.h> 37 37 #include <asm/byteorder.h> 38 + #include <asm/unaligned.h> 38 39 #include <linux/platform_device.h> 39 40 #include <linux/workqueue.h> 40 41 ··· 132 131 0x01, /* __u8 bDeviceProtocol; [ usb 2.0 single TT ]*/ 133 132 0x40, /* __u8 bMaxPacketSize0; 64 Bytes */ 134 133 135 - 0x00, 0x00, /* __le16 idVendor; */ 136 - 0x00, 0x00, /* __le16 idProduct; */ 134 + 0x6b, 0x1d, /* __le16 idVendor; Linux Foundation */ 135 + 0x02, 0x00, /* __le16 idProduct; device 0x0002 */ 137 136 KERNEL_VER, KERNEL_REL, /* __le16 bcdDevice */ 138 137 139 138 0x03, /* __u8 iManufacturer; */ ··· 155 154 0x00, /* __u8 bDeviceProtocol; [ low/full speeds only ] */ 156 155 0x40, /* __u8 bMaxPacketSize0; 64 Bytes */ 157 156 158 - 0x00, 0x00, /* __le16 idVendor; */ 159 - 0x00, 0x00, /* __le16 idProduct; */ 157 + 0x6b, 0x1d, /* __le16 idVendor; Linux Foundation */ 158 + 0x01, 0x00, /* __le16 idProduct; device 0x0001 */ 160 159 KERNEL_VER, KERNEL_REL, /* __le16 bcdDevice */ 161 160 162 161 0x03, /* __u8 iManufacturer; */ ··· 808 807 } 809 808 set_bit (busnum, busmap.busmap); 810 809 bus->busnum = busnum; 811 - bus->class_dev = class_device_create(usb_host_class, NULL, MKDEV(0,0), 812 - bus->controller, "usb_host%d", 813 - busnum); 814 - result = PTR_ERR(bus->class_dev); 815 - if (IS_ERR(bus->class_dev)) 810 + 811 + bus->dev = device_create(usb_host_class, bus->controller, MKDEV(0, 0), 812 + "usb_host%d", busnum); 813 + result = PTR_ERR(bus->dev); 814 + if (IS_ERR(bus->dev)) 816 815 goto error_create_class_dev; 817 - class_set_devdata(bus->class_dev, bus); 816 + dev_set_drvdata(bus->dev, bus); 818 817 819 818 /* Add it to the local list of buses */ 820 819 list_add (&bus->bus_list, &usb_bus_list); ··· 858 857 859 858 clear_bit (bus->busnum, busmap.busmap); 860 859 861 - class_device_unregister(bus->class_dev); 860 + device_unregister(bus->dev); 862 861 } 863 862 864 863 /** ··· 971 970 return -1; 972 971 } 973 972 } 974 - EXPORT_SYMBOL (usb_calc_bus_time); 973 + EXPORT_SYMBOL_GPL(usb_calc_bus_time); 975 974 976 975 977 976 /*-------------------------------------------------------------------------*/ ··· 1113 1112 } 1114 1113 EXPORT_SYMBOL_GPL(usb_hcd_unlink_urb_from_ep); 1115 1114 1116 - static void map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb) 1115 + /* 1116 + * Some usb host controllers can only perform dma using a small SRAM area. 1117 + * The usb core itself is however optimized for host controllers that can dma 1118 + * using regular system memory - like pci devices doing bus mastering. 1119 + * 1120 + * To support host controllers with limited dma capabilites we provide dma 1121 + * bounce buffers. This feature can be enabled using the HCD_LOCAL_MEM flag. 1122 + * For this to work properly the host controller code must first use the 1123 + * function dma_declare_coherent_memory() to point out which memory area 1124 + * that should be used for dma allocations. 1125 + * 1126 + * The HCD_LOCAL_MEM flag then tells the usb code to allocate all data for 1127 + * dma using dma_alloc_coherent() which in turn allocates from the memory 1128 + * area pointed out with dma_declare_coherent_memory(). 1129 + * 1130 + * So, to summarize... 1131 + * 1132 + * - We need "local" memory, canonical example being 1133 + * a small SRAM on a discrete controller being the 1134 + * only memory that the controller can read ... 1135 + * (a) "normal" kernel memory is no good, and 1136 + * (b) there's not enough to share 1137 + * 1138 + * - The only *portable* hook for such stuff in the 1139 + * DMA framework is dma_declare_coherent_memory() 1140 + * 1141 + * - So we use that, even though the primary requirement 1142 + * is that the memory be "local" (hence addressible 1143 + * by that device), not "coherent". 1144 + * 1145 + */ 1146 + 1147 + static int hcd_alloc_coherent(struct usb_bus *bus, 1148 + gfp_t mem_flags, dma_addr_t *dma_handle, 1149 + void **vaddr_handle, size_t size, 1150 + enum dma_data_direction dir) 1117 1151 { 1152 + unsigned char *vaddr; 1153 + 1154 + vaddr = hcd_buffer_alloc(bus, size + sizeof(vaddr), 1155 + mem_flags, dma_handle); 1156 + if (!vaddr) 1157 + return -ENOMEM; 1158 + 1159 + /* 1160 + * Store the virtual address of the buffer at the end 1161 + * of the allocated dma buffer. The size of the buffer 1162 + * may be uneven so use unaligned functions instead 1163 + * of just rounding up. It makes sense to optimize for 1164 + * memory footprint over access speed since the amount 1165 + * of memory available for dma may be limited. 1166 + */ 1167 + put_unaligned((unsigned long)*vaddr_handle, 1168 + (unsigned long *)(vaddr + size)); 1169 + 1170 + if (dir == DMA_TO_DEVICE) 1171 + memcpy(vaddr, *vaddr_handle, size); 1172 + 1173 + *vaddr_handle = vaddr; 1174 + return 0; 1175 + } 1176 + 1177 + static void hcd_free_coherent(struct usb_bus *bus, dma_addr_t *dma_handle, 1178 + void **vaddr_handle, size_t size, 1179 + enum dma_data_direction dir) 1180 + { 1181 + unsigned char *vaddr = *vaddr_handle; 1182 + 1183 + vaddr = (void *)get_unaligned((unsigned long *)(vaddr + size)); 1184 + 1185 + if (dir == DMA_FROM_DEVICE) 1186 + memcpy(vaddr, *vaddr_handle, size); 1187 + 1188 + hcd_buffer_free(bus, size + sizeof(vaddr), *vaddr_handle, *dma_handle); 1189 + 1190 + *vaddr_handle = vaddr; 1191 + *dma_handle = 0; 1192 + } 1193 + 1194 + static int map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb, 1195 + gfp_t mem_flags) 1196 + { 1197 + enum dma_data_direction dir; 1198 + int ret = 0; 1199 + 1118 1200 /* Map the URB's buffers for DMA access. 1119 1201 * Lower level HCD code should use *_dma exclusively, 1120 1202 * unless it uses pio or talks to another transport. 1121 1203 */ 1122 - if (hcd->self.uses_dma && !is_root_hub(urb->dev)) { 1123 - if (usb_endpoint_xfer_control(&urb->ep->desc) 1124 - && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP)) 1125 - urb->setup_dma = dma_map_single ( 1204 + if (is_root_hub(urb->dev)) 1205 + return 0; 1206 + 1207 + if (usb_endpoint_xfer_control(&urb->ep->desc) 1208 + && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP)) { 1209 + if (hcd->self.uses_dma) 1210 + urb->setup_dma = dma_map_single( 1126 1211 hcd->self.controller, 1127 1212 urb->setup_packet, 1128 - sizeof (struct usb_ctrlrequest), 1213 + sizeof(struct usb_ctrlrequest), 1129 1214 DMA_TO_DEVICE); 1130 - if (urb->transfer_buffer_length != 0 1131 - && !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)) 1215 + else if (hcd->driver->flags & HCD_LOCAL_MEM) 1216 + ret = hcd_alloc_coherent( 1217 + urb->dev->bus, mem_flags, 1218 + &urb->setup_dma, 1219 + (void **)&urb->setup_packet, 1220 + sizeof(struct usb_ctrlrequest), 1221 + DMA_TO_DEVICE); 1222 + } 1223 + 1224 + dir = usb_urb_dir_in(urb) ? DMA_FROM_DEVICE : DMA_TO_DEVICE; 1225 + if (ret == 0 && urb->transfer_buffer_length != 0 1226 + && !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)) { 1227 + if (hcd->self.uses_dma) 1132 1228 urb->transfer_dma = dma_map_single ( 1133 1229 hcd->self.controller, 1134 1230 urb->transfer_buffer, 1135 1231 urb->transfer_buffer_length, 1136 - usb_urb_dir_in(urb) 1137 - ? DMA_FROM_DEVICE 1138 - : DMA_TO_DEVICE); 1232 + dir); 1233 + else if (hcd->driver->flags & HCD_LOCAL_MEM) { 1234 + ret = hcd_alloc_coherent( 1235 + urb->dev->bus, mem_flags, 1236 + &urb->transfer_dma, 1237 + &urb->transfer_buffer, 1238 + urb->transfer_buffer_length, 1239 + dir); 1240 + 1241 + if (ret && usb_endpoint_xfer_control(&urb->ep->desc) 1242 + && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP)) 1243 + hcd_free_coherent(urb->dev->bus, 1244 + &urb->setup_dma, 1245 + (void **)&urb->setup_packet, 1246 + sizeof(struct usb_ctrlrequest), 1247 + DMA_TO_DEVICE); 1248 + } 1139 1249 } 1250 + return ret; 1140 1251 } 1141 1252 1142 1253 static void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb) 1143 1254 { 1144 - if (hcd->self.uses_dma && !is_root_hub(urb->dev)) { 1145 - if (usb_endpoint_xfer_control(&urb->ep->desc) 1146 - && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP)) 1255 + enum dma_data_direction dir; 1256 + 1257 + if (is_root_hub(urb->dev)) 1258 + return; 1259 + 1260 + if (usb_endpoint_xfer_control(&urb->ep->desc) 1261 + && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP)) { 1262 + if (hcd->self.uses_dma) 1147 1263 dma_unmap_single(hcd->self.controller, urb->setup_dma, 1148 1264 sizeof(struct usb_ctrlrequest), 1149 1265 DMA_TO_DEVICE); 1150 - if (urb->transfer_buffer_length != 0 1151 - && !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)) 1266 + else if (hcd->driver->flags & HCD_LOCAL_MEM) 1267 + hcd_free_coherent(urb->dev->bus, &urb->setup_dma, 1268 + (void **)&urb->setup_packet, 1269 + sizeof(struct usb_ctrlrequest), 1270 + DMA_TO_DEVICE); 1271 + } 1272 + 1273 + dir = usb_urb_dir_in(urb) ? DMA_FROM_DEVICE : DMA_TO_DEVICE; 1274 + if (urb->transfer_buffer_length != 0 1275 + && !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)) { 1276 + if (hcd->self.uses_dma) 1152 1277 dma_unmap_single(hcd->self.controller, 1153 1278 urb->transfer_dma, 1154 1279 urb->transfer_buffer_length, 1155 - usb_urb_dir_in(urb) 1156 - ? DMA_FROM_DEVICE 1157 - : DMA_TO_DEVICE); 1280 + dir); 1281 + else if (hcd->driver->flags & HCD_LOCAL_MEM) 1282 + hcd_free_coherent(urb->dev->bus, &urb->transfer_dma, 1283 + &urb->transfer_buffer, 1284 + urb->transfer_buffer_length, 1285 + dir); 1158 1286 } 1159 1287 } 1160 1288 ··· 1315 1185 * URBs must be submitted in process context with interrupts 1316 1186 * enabled. 1317 1187 */ 1318 - map_urb_for_dma(hcd, urb); 1188 + status = map_urb_for_dma(hcd, urb, mem_flags); 1189 + if (unlikely(status)) { 1190 + usbmon_urb_submit_error(&hcd->self, urb, status); 1191 + goto error; 1192 + } 1193 + 1319 1194 if (is_root_hub(urb->dev)) 1320 1195 status = rh_urb_enqueue(hcd, urb); 1321 1196 else ··· 1329 1194 if (unlikely(status)) { 1330 1195 usbmon_urb_submit_error(&hcd->self, urb, status); 1331 1196 unmap_urb_for_dma(hcd, urb); 1197 + error: 1332 1198 urb->hcpriv = NULL; 1333 1199 INIT_LIST_HEAD(&urb->urb_list); 1334 1200 atomic_dec(&urb->use_count); ··· 1427 1291 wake_up (&usb_kill_urb_queue); 1428 1292 usb_put_urb (urb); 1429 1293 } 1430 - EXPORT_SYMBOL (usb_hcd_giveback_urb); 1294 + EXPORT_SYMBOL_GPL(usb_hcd_giveback_urb); 1431 1295 1432 1296 /*-------------------------------------------------------------------------*/ 1433 1297 ··· 1667 1531 mod_timer(&hcd->rh_timer, jiffies + msecs_to_jiffies(10)); 1668 1532 return status; 1669 1533 } 1670 - EXPORT_SYMBOL (usb_bus_start_enum); 1534 + EXPORT_SYMBOL_GPL(usb_bus_start_enum); 1671 1535 1672 1536 #endif 1673 1537 ··· 1774 1638 "USB Host Controller"; 1775 1639 return hcd; 1776 1640 } 1777 - EXPORT_SYMBOL (usb_create_hcd); 1641 + EXPORT_SYMBOL_GPL(usb_create_hcd); 1778 1642 1779 1643 static void hcd_release (struct kref *kref) 1780 1644 { ··· 1789 1653 kref_get (&hcd->kref); 1790 1654 return hcd; 1791 1655 } 1792 - EXPORT_SYMBOL (usb_get_hcd); 1656 + EXPORT_SYMBOL_GPL(usb_get_hcd); 1793 1657 1794 1658 void usb_put_hcd (struct usb_hcd *hcd) 1795 1659 { 1796 1660 if (hcd) 1797 1661 kref_put (&hcd->kref, hcd_release); 1798 1662 } 1799 - EXPORT_SYMBOL (usb_put_hcd); 1663 + EXPORT_SYMBOL_GPL(usb_put_hcd); 1800 1664 1801 1665 /** 1802 1666 * usb_add_hcd - finish generic HCD structure initialization and register ··· 1922 1786 hcd_buffer_destroy(hcd); 1923 1787 return retval; 1924 1788 } 1925 - EXPORT_SYMBOL (usb_add_hcd); 1789 + EXPORT_SYMBOL_GPL(usb_add_hcd); 1926 1790 1927 1791 /** 1928 1792 * usb_remove_hcd - shutdown processing for generic HCDs ··· 1964 1828 usb_deregister_bus(&hcd->self); 1965 1829 hcd_buffer_destroy(hcd); 1966 1830 } 1967 - EXPORT_SYMBOL (usb_remove_hcd); 1831 + EXPORT_SYMBOL_GPL(usb_remove_hcd); 1968 1832 1969 1833 void 1970 1834 usb_hcd_platform_shutdown(struct platform_device* dev) ··· 1974 1838 if (hcd->driver->shutdown) 1975 1839 hcd->driver->shutdown(hcd); 1976 1840 } 1977 - EXPORT_SYMBOL (usb_hcd_platform_shutdown); 1841 + EXPORT_SYMBOL_GPL(usb_hcd_platform_shutdown); 1978 1842 1979 1843 /*-------------------------------------------------------------------------*/ 1980 1844
+48 -44
drivers/usb/core/hcd.h
··· 125 125 126 126 /* more shared queuing code would be good; it should support 127 127 * smarter scheduling, handle transaction translators, etc; 128 - * input size of periodic table to an interrupt scheduler. 128 + * input size of periodic table to an interrupt scheduler. 129 129 * (ohci 32, uhci 1024, ehci 256/512/1024). 130 130 */ 131 131 ··· 133 133 * this structure. 134 134 */ 135 135 unsigned long hcd_priv[0] 136 - __attribute__ ((aligned (sizeof(unsigned long)))); 136 + __attribute__ ((aligned(sizeof(unsigned long)))); 137 137 }; 138 138 139 139 /* 2.4 does this a bit differently ... */ 140 - static inline struct usb_bus *hcd_to_bus (struct usb_hcd *hcd) 140 + static inline struct usb_bus *hcd_to_bus(struct usb_hcd *hcd) 141 141 { 142 142 return &hcd->self; 143 143 } 144 144 145 - static inline struct usb_hcd *bus_to_hcd (struct usb_bus *bus) 145 + static inline struct usb_hcd *bus_to_hcd(struct usb_bus *bus) 146 146 { 147 147 return container_of(bus, struct usb_hcd, self); 148 148 } ··· 165 165 166 166 int flags; 167 167 #define HCD_MEMORY 0x0001 /* HC regs use memory (else I/O) */ 168 + #define HCD_LOCAL_MEM 0x0002 /* HC needs local memory */ 168 169 #define HCD_USB11 0x0010 /* USB 1.1 */ 169 170 #define HCD_USB2 0x0020 /* USB 2.0 */ 170 171 ··· 202 201 struct usb_host_endpoint *ep); 203 202 204 203 /* root hub support */ 205 - int (*hub_status_data) (struct usb_hcd *hcd, char *buf); 206 - int (*hub_control) (struct usb_hcd *hcd, 204 + int (*hub_status_data) (struct usb_hcd *hcd, char *buf); 205 + int (*hub_control) (struct usb_hcd *hcd, 207 206 u16 typeReq, u16 wValue, u16 wIndex, 208 207 char *buf, u16 wLength); 209 - int (*bus_suspend)(struct usb_hcd *); 210 - int (*bus_resume)(struct usb_hcd *); 211 - int (*start_port_reset)(struct usb_hcd *, unsigned port_num); 212 - void (*hub_irq_enable)(struct usb_hcd *); 208 + int (*bus_suspend)(struct usb_hcd *); 209 + int (*bus_resume)(struct usb_hcd *); 210 + int (*start_port_reset)(struct usb_hcd *, unsigned port_num); 211 + void (*hub_irq_enable)(struct usb_hcd *); 213 212 /* Needed only if port-change IRQs are level-triggered */ 213 + 214 + /* force handover of high-speed port to full-speed companion */ 215 + void (*relinquish_port)(struct usb_hcd *, int); 214 216 }; 215 217 216 218 extern int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb); ··· 221 217 int status); 222 218 extern void usb_hcd_unlink_urb_from_ep(struct usb_hcd *hcd, struct urb *urb); 223 219 224 - extern int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags); 225 - extern int usb_hcd_unlink_urb (struct urb *urb, int status); 220 + extern int usb_hcd_submit_urb(struct urb *urb, gfp_t mem_flags); 221 + extern int usb_hcd_unlink_urb(struct urb *urb, int status); 226 222 extern void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, 227 223 int status); 228 224 extern void usb_hcd_flush_endpoint(struct usb_device *udev, 229 225 struct usb_host_endpoint *ep); 230 226 extern void usb_hcd_disable_endpoint(struct usb_device *udev, 231 227 struct usb_host_endpoint *ep); 232 - extern int usb_hcd_get_frame_number (struct usb_device *udev); 228 + extern int usb_hcd_get_frame_number(struct usb_device *udev); 233 229 234 - extern struct usb_hcd *usb_create_hcd (const struct hc_driver *driver, 230 + extern struct usb_hcd *usb_create_hcd(const struct hc_driver *driver, 235 231 struct device *dev, char *bus_name); 236 - extern struct usb_hcd *usb_get_hcd (struct usb_hcd *hcd); 237 - extern void usb_put_hcd (struct usb_hcd *hcd); 232 + extern struct usb_hcd *usb_get_hcd(struct usb_hcd *hcd); 233 + extern void usb_put_hcd(struct usb_hcd *hcd); 238 234 extern int usb_add_hcd(struct usb_hcd *hcd, 239 235 unsigned int irqnum, unsigned long irqflags); 240 236 extern void usb_remove_hcd(struct usb_hcd *hcd); 241 237 242 238 struct platform_device; 243 - extern void usb_hcd_platform_shutdown(struct platform_device* dev); 239 + extern void usb_hcd_platform_shutdown(struct platform_device *dev); 244 240 245 241 #ifdef CONFIG_PCI 246 242 struct pci_dev; 247 243 struct pci_device_id; 248 - extern int usb_hcd_pci_probe (struct pci_dev *dev, 244 + extern int usb_hcd_pci_probe(struct pci_dev *dev, 249 245 const struct pci_device_id *id); 250 - extern void usb_hcd_pci_remove (struct pci_dev *dev); 246 + extern void usb_hcd_pci_remove(struct pci_dev *dev); 251 247 252 248 #ifdef CONFIG_PM 253 - extern int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t state); 254 - extern int usb_hcd_pci_resume (struct pci_dev *dev); 249 + extern int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t state); 250 + extern int usb_hcd_pci_resume(struct pci_dev *dev); 255 251 #endif /* CONFIG_PM */ 256 252 257 - extern void usb_hcd_pci_shutdown (struct pci_dev *dev); 253 + extern void usb_hcd_pci_shutdown(struct pci_dev *dev); 258 254 259 255 #endif /* CONFIG_PCI */ 260 256 261 257 /* pci-ish (pdev null is ok) buffer alloc/mapping support */ 262 - int hcd_buffer_create (struct usb_hcd *hcd); 263 - void hcd_buffer_destroy (struct usb_hcd *hcd); 258 + int hcd_buffer_create(struct usb_hcd *hcd); 259 + void hcd_buffer_destroy(struct usb_hcd *hcd); 264 260 265 - void *hcd_buffer_alloc (struct usb_bus *bus, size_t size, 261 + void *hcd_buffer_alloc(struct usb_bus *bus, size_t size, 266 262 gfp_t mem_flags, dma_addr_t *dma); 267 - void hcd_buffer_free (struct usb_bus *bus, size_t size, 263 + void hcd_buffer_free(struct usb_bus *bus, size_t size, 268 264 void *addr, dma_addr_t dma); 269 265 270 266 /* generic bus glue, needed for host controllers that don't use PCI */ 271 - extern irqreturn_t usb_hcd_irq (int irq, void *__hcd); 267 + extern irqreturn_t usb_hcd_irq(int irq, void *__hcd); 272 268 273 - extern void usb_hc_died (struct usb_hcd *hcd); 269 + extern void usb_hc_died(struct usb_hcd *hcd); 274 270 extern void usb_hcd_poll_rh_status(struct usb_hcd *hcd); 275 271 276 272 /* -------------------------------------------------------------------------- */ ··· 323 319 * Generic bandwidth allocation constants/support 324 320 */ 325 321 #define FRAME_TIME_USECS 1000L 326 - #define BitTime(bytecount) (7 * 8 * bytecount / 6) /* with integer truncation */ 322 + #define BitTime(bytecount) (7 * 8 * bytecount / 6) /* with integer truncation */ 327 323 /* Trying not to use worst-case bit-stuffing 328 - of (7/6 * 8 * bytecount) = 9.33 * bytecount */ 324 + * of (7/6 * 8 * bytecount) = 9.33 * bytecount */ 329 325 /* bytecount = data payload byte count */ 330 326 331 327 #define NS_TO_US(ns) ((ns + 500L) / 1000L) ··· 337 333 */ 338 334 #define BW_HOST_DELAY 1000L /* nanoseconds */ 339 335 #define BW_HUB_LS_SETUP 333L /* nanoseconds */ 340 - /* 4 full-speed bit times (est.) */ 336 + /* 4 full-speed bit times (est.) */ 341 337 342 - #define FRAME_TIME_BITS 12000L /* frame = 1 millisecond */ 338 + #define FRAME_TIME_BITS 12000L /* frame = 1 millisecond */ 343 339 #define FRAME_TIME_MAX_BITS_ALLOC (90L * FRAME_TIME_BITS / 100L) 344 340 #define FRAME_TIME_MAX_USECS_ALLOC (90L * FRAME_TIME_USECS / 100L) 345 341 ··· 349 345 * to preallocate bandwidth) 350 346 */ 351 347 #define USB2_HOST_DELAY 5 /* nsec, guess */ 352 - #define HS_NSECS(bytes) ( ((55 * 8 * 2083) \ 348 + #define HS_NSECS(bytes) (((55 * 8 * 2083) \ 353 349 + (2083UL * (3 + BitTime(bytes))))/1000 \ 354 350 + USB2_HOST_DELAY) 355 - #define HS_NSECS_ISO(bytes) ( ((38 * 8 * 2083) \ 351 + #define HS_NSECS_ISO(bytes) (((38 * 8 * 2083) \ 356 352 + (2083UL * (3 + BitTime(bytes))))/1000 \ 357 353 + USB2_HOST_DELAY) 358 354 #define HS_USECS(bytes) NS_TO_US (HS_NSECS(bytes)) 359 355 #define HS_USECS_ISO(bytes) NS_TO_US (HS_NSECS_ISO(bytes)) 360 356 361 - extern long usb_calc_bus_time (int speed, int is_input, 357 + extern long usb_calc_bus_time(int speed, int is_input, 362 358 int isoc, int bytecount); 363 359 364 360 /*-------------------------------------------------------------------------*/ ··· 374 370 extern struct mutex usb_bus_list_lock; 375 371 extern wait_queue_head_t usb_kill_urb_queue; 376 372 377 - extern void usb_enable_root_hub_irq (struct usb_bus *bus); 373 + extern void usb_enable_root_hub_irq(struct usb_bus *bus); 378 374 379 - extern int usb_find_interface_driver (struct usb_device *dev, 375 + extern int usb_find_interface_driver(struct usb_device *dev, 380 376 struct usb_interface *interface); 381 377 382 378 #define usb_endpoint_out(ep_dir) (!((ep_dir) & USB_DIR_IN)) 383 379 384 380 #ifdef CONFIG_PM 385 - extern void usb_hcd_resume_root_hub (struct usb_hcd *hcd); 386 - extern void usb_root_hub_lost_power (struct usb_device *rhdev); 381 + extern void usb_hcd_resume_root_hub(struct usb_hcd *hcd); 382 + extern void usb_root_hub_lost_power(struct usb_device *rhdev); 387 383 extern int hcd_bus_suspend(struct usb_device *rhdev); 388 384 extern int hcd_bus_resume(struct usb_device *rhdev); 389 385 #else ··· 403 399 * these are expected to be called from the USB core/hub thread 404 400 * with the kernel lock held 405 401 */ 406 - extern void usbfs_update_special (void); 402 + extern void usbfs_update_special(void); 407 403 extern int usbfs_init(void); 408 404 extern void usbfs_cleanup(void); 409 405 410 406 #else /* CONFIG_USB_DEVICEFS */ 411 407 412 - static inline void usbfs_update_special (void) {} 408 + static inline void usbfs_update_special(void) {} 413 409 static inline int usbfs_init(void) { return 0; } 414 410 static inline void usbfs_cleanup(void) { } 415 411 ··· 464 460 /*-------------------------------------------------------------------------*/ 465 461 466 462 /* hub.h ... DeviceRemovable in 2.4.2-ac11, gone in 2.4.10 */ 467 - // bleech -- resurfaced in 2.4.11 or 2.4.12 463 + /* bleech -- resurfaced in 2.4.11 or 2.4.12 */ 468 464 #define bitmap DeviceRemovable 469 465 470 466 ··· 472 468 473 469 /* random stuff */ 474 470 475 - #define RUN_CONTEXT (in_irq () ? "in_irq" \ 476 - : (in_interrupt () ? "in_interrupt" : "can sleep")) 471 + #define RUN_CONTEXT (in_irq() ? "in_irq" \ 472 + : (in_interrupt() ? "in_interrupt" : "can sleep")) 477 473 478 474 479 475 /* This rwsem is for use only by the hub driver and ehci-hcd.
+49 -39
drivers/usb/core/hub.c
··· 37 37 #define USB_PERSIST 0 38 38 #endif 39 39 40 + /* if we are in debug mode, always announce new devices */ 41 + #ifdef DEBUG 42 + #ifndef CONFIG_USB_ANNOUNCE_NEW_DEVICES 43 + #define CONFIG_USB_ANNOUNCE_NEW_DEVICES 44 + #endif 45 + #endif 46 + 40 47 struct usb_hub { 41 48 struct device *intfdev; /* the "interface" device */ 42 49 struct usb_device *hdev; ··· 494 487 schedule_work (&tt->kevent); 495 488 spin_unlock_irqrestore (&tt->lock, flags); 496 489 } 490 + EXPORT_SYMBOL_GPL(usb_hub_tt_clear_buffer); 497 491 498 492 static void hub_power_on(struct usb_hub *hub) 499 493 { ··· 1035 1027 if (udev->children[i]) 1036 1028 recursively_mark_NOTATTACHED(udev->children[i]); 1037 1029 } 1038 - if (udev->state == USB_STATE_SUSPENDED) 1030 + if (udev->state == USB_STATE_SUSPENDED) { 1039 1031 udev->discon_suspended = 1; 1032 + udev->active_duration -= jiffies; 1033 + } 1040 1034 udev->state = USB_STATE_NOTATTACHED; 1041 1035 } 1042 1036 ··· 1087 1077 else 1088 1078 device_init_wakeup(&udev->dev, 0); 1089 1079 } 1080 + if (udev->state == USB_STATE_SUSPENDED && 1081 + new_state != USB_STATE_SUSPENDED) 1082 + udev->active_duration -= jiffies; 1083 + else if (new_state == USB_STATE_SUSPENDED && 1084 + udev->state != USB_STATE_SUSPENDED) 1085 + udev->active_duration += jiffies; 1090 1086 udev->state = new_state; 1091 1087 } else 1092 1088 recursively_mark_NOTATTACHED(udev); ··· 1223 1207 put_device(&udev->dev); 1224 1208 } 1225 1209 1226 - #ifdef DEBUG 1210 + #ifdef CONFIG_USB_ANNOUNCE_NEW_DEVICES 1227 1211 static void show_string(struct usb_device *udev, char *id, char *string) 1228 1212 { 1229 1213 if (!string) ··· 1231 1215 dev_printk(KERN_INFO, &udev->dev, "%s: %s\n", id, string); 1232 1216 } 1233 1217 1218 + static void announce_device(struct usb_device *udev) 1219 + { 1220 + dev_info(&udev->dev, "New USB device found, idVendor=%04x, idProduct=%04x\n", 1221 + le16_to_cpu(udev->descriptor.idVendor), 1222 + le16_to_cpu(udev->descriptor.idProduct)); 1223 + dev_info(&udev->dev, "New USB device strings: Mfr=%d, Product=%d, " 1224 + "SerialNumber=%d\n", 1225 + udev->descriptor.iManufacturer, 1226 + udev->descriptor.iProduct, 1227 + udev->descriptor.iSerialNumber); 1228 + show_string(udev, "Product", udev->product); 1229 + show_string(udev, "Manufacturer", udev->manufacturer); 1230 + show_string(udev, "SerialNumber", udev->serial); 1231 + } 1234 1232 #else 1235 - static inline void show_string(struct usb_device *udev, char *id, char *string) 1236 - {} 1233 + static inline void announce_device(struct usb_device *udev) { } 1237 1234 #endif 1238 - 1239 1235 1240 1236 #ifdef CONFIG_USB_OTG 1241 1237 #include "otg_whitelist.h" ··· 1418 1390 } 1419 1391 1420 1392 /* Tell the world! */ 1421 - dev_dbg(&udev->dev, "new device strings: Mfr=%d, Product=%d, " 1422 - "SerialNumber=%d\n", 1423 - udev->descriptor.iManufacturer, 1424 - udev->descriptor.iProduct, 1425 - udev->descriptor.iSerialNumber); 1426 - show_string(udev, "Product", udev->product); 1427 - show_string(udev, "Manufacturer", udev->manufacturer); 1428 - show_string(udev, "SerialNumber", udev->serial); 1393 + announce_device(udev); 1429 1394 return err; 1430 1395 1431 1396 fail: ··· 2503 2482 { 2504 2483 struct usb_device *hdev = hub->hdev; 2505 2484 struct device *hub_dev = hub->intfdev; 2485 + struct usb_hcd *hcd = bus_to_hcd(hdev->bus); 2506 2486 u16 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); 2507 2487 int status, i; 2508 2488 ··· 2667 2645 2668 2646 done: 2669 2647 hub_port_disable(hub, port1, 1); 2648 + if (hcd->driver->relinquish_port && !hub->hdev->parent) 2649 + hcd->driver->relinquish_port(hcd, port1); 2670 2650 } 2671 2651 2672 2652 static void hub_events(void) ··· 2970 2946 if (len < le16_to_cpu(udev->config[index].desc.wTotalLength)) 2971 2947 len = le16_to_cpu(udev->config[index].desc.wTotalLength); 2972 2948 } 2973 - buf = kmalloc (len, GFP_KERNEL); 2949 + buf = kmalloc(len, GFP_NOIO); 2974 2950 if (buf == NULL) { 2975 2951 dev_err(&udev->dev, "no mem to re-read configs after reset\n"); 2976 2952 /* assume the worst */ ··· 3117 3093 hub_port_logical_disconnect(parent_hub, port1); 3118 3094 return -ENODEV; 3119 3095 } 3120 - EXPORT_SYMBOL(usb_reset_device); 3096 + EXPORT_SYMBOL_GPL(usb_reset_device); 3121 3097 3122 3098 /** 3123 3099 * usb_reset_composite_device - warn interface drivers and perform a USB port reset ··· 3134 3110 * this from a driver probe() routine after downloading new firmware. 3135 3111 * For calls that might not occur during probe(), drivers should lock 3136 3112 * the device using usb_lock_device_for_reset(). 3137 - * 3138 - * The interface locks are acquired during the pre_reset stage and released 3139 - * during the post_reset stage. However if iface is not NULL and is 3140 - * currently being probed, we assume that the caller already owns its 3141 - * lock. 3142 3113 */ 3143 3114 int usb_reset_composite_device(struct usb_device *udev, 3144 3115 struct usb_interface *iface) 3145 3116 { 3146 3117 int ret; 3118 + int i; 3147 3119 struct usb_host_config *config = udev->actconfig; 3148 3120 3149 3121 if (udev->state == USB_STATE_NOTATTACHED || ··· 3156 3136 iface = NULL; 3157 3137 3158 3138 if (config) { 3159 - int i; 3160 - struct usb_interface *cintf; 3161 - struct usb_driver *drv; 3162 - 3163 3139 for (i = 0; i < config->desc.bNumInterfaces; ++i) { 3164 - cintf = config->interface[i]; 3165 - if (cintf != iface) 3166 - down(&cintf->dev.sem); 3167 - if (device_is_registered(&cintf->dev) && 3168 - cintf->dev.driver) { 3140 + struct usb_interface *cintf = config->interface[i]; 3141 + struct usb_driver *drv; 3142 + 3143 + if (cintf->dev.driver) { 3169 3144 drv = to_usb_driver(cintf->dev.driver); 3170 3145 if (drv->pre_reset) 3171 3146 (drv->pre_reset)(cintf); ··· 3172 3157 ret = usb_reset_device(udev); 3173 3158 3174 3159 if (config) { 3175 - int i; 3176 - struct usb_interface *cintf; 3177 - struct usb_driver *drv; 3178 - 3179 3160 for (i = config->desc.bNumInterfaces - 1; i >= 0; --i) { 3180 - cintf = config->interface[i]; 3181 - if (device_is_registered(&cintf->dev) && 3182 - cintf->dev.driver) { 3161 + struct usb_interface *cintf = config->interface[i]; 3162 + struct usb_driver *drv; 3163 + 3164 + if (cintf->dev.driver) { 3183 3165 drv = to_usb_driver(cintf->dev.driver); 3184 3166 if (drv->post_reset) 3185 3167 (drv->post_reset)(cintf); 3186 3168 /* FIXME: Unbind if post_reset returns an error or isn't defined */ 3187 3169 } 3188 - if (cintf != iface) 3189 - up(&cintf->dev.sem); 3190 3170 } 3191 3171 } 3192 3172 3193 3173 usb_autosuspend_device(udev); 3194 3174 return ret; 3195 3175 } 3196 - EXPORT_SYMBOL(usb_reset_composite_device); 3176 + EXPORT_SYMBOL_GPL(usb_reset_composite_device);
+9 -9
drivers/usb/core/hub.h
··· 55 55 #define USB_PORT_FEAT_TEST 21 56 56 #define USB_PORT_FEAT_INDICATOR 22 57 57 58 - /* 58 + /* 59 59 * Hub Status and Hub Change results 60 60 * See USB 2.0 spec Table 11-19 and Table 11-20 61 61 */ 62 62 struct usb_port_status { 63 63 __le16 wPortStatus; 64 - __le16 wPortChange; 64 + __le16 wPortChange; 65 65 } __attribute__ ((packed)); 66 66 67 - /* 67 + /* 68 68 * wPortStatus bit field 69 69 * See USB 2.0 spec Table 11-21 70 70 */ ··· 81 81 #define USB_PORT_STAT_INDICATOR 0x1000 82 82 /* bits 13 to 15 are reserved */ 83 83 84 - /* 84 + /* 85 85 * wPortChange bit field 86 86 * See USB 2.0 spec Table 11-22 87 87 * Bits 0 to 4 shown, bits 5 to 15 are reserved ··· 93 93 #define USB_PORT_STAT_C_RESET 0x0010 94 94 95 95 /* 96 - * wHubCharacteristics (masks) 96 + * wHubCharacteristics (masks) 97 97 * See USB 2.0 spec Table 11-13, offset 3 98 98 */ 99 99 #define HUB_CHAR_LPSM 0x0003 /* D1 .. D0 */ ··· 119 119 #define HUB_CHANGE_OVERCURRENT 0x0002 120 120 121 121 122 - /* 123 - * Hub descriptor 122 + /* 123 + * Hub descriptor 124 124 * See USB 2.0 spec Table 11-13 125 125 */ 126 126 ··· 134 134 __le16 wHubCharacteristics; 135 135 __u8 bPwrOn2PwrGood; 136 136 __u8 bHubContrCurrent; 137 - /* add 1 bit for hub status change; round to bytes */ 137 + /* add 1 bit for hub status change; round to bytes */ 138 138 __u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8]; 139 139 __u8 PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8]; 140 140 } __attribute__ ((packed)); ··· 190 190 u16 devinfo; 191 191 }; 192 192 193 - extern void usb_hub_tt_clear_buffer (struct usb_device *dev, int pipe); 193 + extern void usb_hub_tt_clear_buffer(struct usb_device *dev, int pipe); 194 194 195 195 #endif /* __LINUX_HUB_H */
+36 -6
drivers/usb/core/inode.c
··· 38 38 #include <linux/usbdevice_fs.h> 39 39 #include <linux/parser.h> 40 40 #include <linux/notifier.h> 41 + #include <linux/seq_file.h> 41 42 #include <asm/byteorder.h> 42 43 #include "usb.h" 43 44 #include "hcd.h" 45 + 46 + #define USBFS_DEFAULT_DEVMODE (S_IWUSR | S_IRUGO) 47 + #define USBFS_DEFAULT_BUSMODE (S_IXUGO | S_IRUGO) 48 + #define USBFS_DEFAULT_LISTMODE S_IRUGO 44 49 45 50 static struct super_operations usbfs_ops; 46 51 static const struct file_operations default_file_operations; ··· 62 57 static gid_t devgid; /* = 0 */ 63 58 static gid_t busgid; /* = 0 */ 64 59 static gid_t listgid; /* = 0 */ 65 - static umode_t devmode = S_IWUSR | S_IRUGO; 66 - static umode_t busmode = S_IXUGO | S_IRUGO; 67 - static umode_t listmode = S_IRUGO; 60 + static umode_t devmode = USBFS_DEFAULT_DEVMODE; 61 + static umode_t busmode = USBFS_DEFAULT_BUSMODE; 62 + static umode_t listmode = USBFS_DEFAULT_LISTMODE; 63 + 64 + static int usbfs_show_options(struct seq_file *seq, struct vfsmount *mnt) 65 + { 66 + if (devuid != 0) 67 + seq_printf(seq, ",devuid=%u", devuid); 68 + if (devgid != 0) 69 + seq_printf(seq, ",devgid=%u", devgid); 70 + if (devmode != USBFS_DEFAULT_DEVMODE) 71 + seq_printf(seq, ",devmode=%o", devmode); 72 + if (busuid != 0) 73 + seq_printf(seq, ",busuid=%u", busuid); 74 + if (busgid != 0) 75 + seq_printf(seq, ",busgid=%u", busgid); 76 + if (busmode != USBFS_DEFAULT_BUSMODE) 77 + seq_printf(seq, ",busmode=%o", busmode); 78 + if (listuid != 0) 79 + seq_printf(seq, ",listuid=%u", listuid); 80 + if (listgid != 0) 81 + seq_printf(seq, ",listgid=%u", listgid); 82 + if (listmode != USBFS_DEFAULT_LISTMODE) 83 + seq_printf(seq, ",listmode=%o", listmode); 84 + 85 + return 0; 86 + } 68 87 69 88 enum { 70 89 Opt_devuid, Opt_devgid, Opt_devmode, ··· 122 93 devgid = 0; 123 94 busgid = 0; 124 95 listgid = 0; 125 - devmode = S_IWUSR | S_IRUGO; 126 - busmode = S_IXUGO | S_IRUGO; 127 - listmode = S_IRUGO; 96 + devmode = USBFS_DEFAULT_DEVMODE; 97 + busmode = USBFS_DEFAULT_BUSMODE; 98 + listmode = USBFS_DEFAULT_LISTMODE; 128 99 129 100 while ((p = strsep(&data, ",")) != NULL) { 130 101 substring_t args[MAX_OPT_ARGS]; ··· 447 418 .statfs = simple_statfs, 448 419 .drop_inode = generic_delete_inode, 449 420 .remount_fs = remount, 421 + .show_options = usbfs_show_options, 450 422 }; 451 423 452 424 static int usbfs_fill_super(struct super_block *sb, void *data, int silent)
+210 -210
drivers/usb/core/message.c
··· 39 39 * own interruptible routines. 40 40 */ 41 41 static int usb_start_wait_urb(struct urb *urb, int timeout, int *actual_length) 42 - { 42 + { 43 43 struct api_context ctx; 44 44 unsigned long expire; 45 45 int retval; ··· 74 74 } 75 75 76 76 /*-------------------------------------------------------------------*/ 77 - // returns status (negative) or length (positive) 77 + /* returns status (negative) or length (positive) */ 78 78 static int usb_internal_control_msg(struct usb_device *usb_dev, 79 - unsigned int pipe, 79 + unsigned int pipe, 80 80 struct usb_ctrlrequest *cmd, 81 81 void *data, int len, int timeout) 82 82 { ··· 87 87 urb = usb_alloc_urb(0, GFP_NOIO); 88 88 if (!urb) 89 89 return -ENOMEM; 90 - 90 + 91 91 usb_fill_control_urb(urb, usb_dev, pipe, (unsigned char *)cmd, data, 92 92 len, usb_api_blocking_completion, NULL); 93 93 ··· 99 99 } 100 100 101 101 /** 102 - * usb_control_msg - Builds a control urb, sends it off and waits for completion 103 - * @dev: pointer to the usb device to send the message to 104 - * @pipe: endpoint "pipe" to send the message to 105 - * @request: USB message request value 106 - * @requesttype: USB message request type value 107 - * @value: USB message value 108 - * @index: USB message index value 109 - * @data: pointer to the data to send 110 - * @size: length in bytes of the data to send 111 - * @timeout: time in msecs to wait for the message to complete before 112 - * timing out (if 0 the wait is forever) 113 - * Context: !in_interrupt () 102 + * usb_control_msg - Builds a control urb, sends it off and waits for completion 103 + * @dev: pointer to the usb device to send the message to 104 + * @pipe: endpoint "pipe" to send the message to 105 + * @request: USB message request value 106 + * @requesttype: USB message request type value 107 + * @value: USB message value 108 + * @index: USB message index value 109 + * @data: pointer to the data to send 110 + * @size: length in bytes of the data to send 111 + * @timeout: time in msecs to wait for the message to complete before timing 112 + * out (if 0 the wait is forever) 114 113 * 115 - * This function sends a simple control message to a specified endpoint 116 - * and waits for the message to complete, or timeout. 117 - * 118 - * If successful, it returns the number of bytes transferred, otherwise a negative error number. 114 + * Context: !in_interrupt () 119 115 * 120 - * Don't use this function from within an interrupt context, like a 121 - * bottom half handler. If you need an asynchronous message, or need to send 122 - * a message from within interrupt context, use usb_submit_urb() 123 - * If a thread in your driver uses this call, make sure your disconnect() 124 - * method can wait for it to complete. Since you don't have a handle on 125 - * the URB used, you can't cancel the request. 116 + * This function sends a simple control message to a specified endpoint and 117 + * waits for the message to complete, or timeout. 118 + * 119 + * If successful, it returns the number of bytes transferred, otherwise a 120 + * negative error number. 121 + * 122 + * Don't use this function from within an interrupt context, like a bottom half 123 + * handler. If you need an asynchronous message, or need to send a message 124 + * from within interrupt context, use usb_submit_urb(). 125 + * If a thread in your driver uses this call, make sure your disconnect() 126 + * method can wait for it to complete. Since you don't have a handle on the 127 + * URB used, you can't cancel the request. 126 128 */ 127 - int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u8 requesttype, 128 - __u16 value, __u16 index, void *data, __u16 size, int timeout) 129 + int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, 130 + __u8 requesttype, __u16 value, __u16 index, void *data, 131 + __u16 size, int timeout) 129 132 { 130 - struct usb_ctrlrequest *dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO); 133 + struct usb_ctrlrequest *dr; 131 134 int ret; 132 - 135 + 136 + dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO); 133 137 if (!dr) 134 138 return -ENOMEM; 135 139 136 - dr->bRequestType= requesttype; 140 + dr->bRequestType = requesttype; 137 141 dr->bRequest = request; 138 142 dr->wValue = cpu_to_le16p(&value); 139 143 dr->wIndex = cpu_to_le16p(&index); 140 144 dr->wLength = cpu_to_le16p(&size); 141 145 142 - //dbg("usb_control_msg"); 146 + /* dbg("usb_control_msg"); */ 143 147 144 148 ret = usb_internal_control_msg(dev, pipe, dr, data, size, timeout); 145 149 ··· 151 147 152 148 return ret; 153 149 } 154 - 150 + EXPORT_SYMBOL_GPL(usb_control_msg); 155 151 156 152 /** 157 153 * usb_interrupt_msg - Builds an interrupt urb, sends it off and waits for completion ··· 159 155 * @pipe: endpoint "pipe" to send the message to 160 156 * @data: pointer to the data to send 161 157 * @len: length in bytes of the data to send 162 - * @actual_length: pointer to a location to put the actual length transferred in bytes 158 + * @actual_length: pointer to a location to put the actual length transferred 159 + * in bytes 163 160 * @timeout: time in msecs to wait for the message to complete before 164 161 * timing out (if 0 the wait is forever) 162 + * 165 163 * Context: !in_interrupt () 166 164 * 167 165 * This function sends a simple interrupt message to a specified endpoint and ··· 187 181 EXPORT_SYMBOL_GPL(usb_interrupt_msg); 188 182 189 183 /** 190 - * usb_bulk_msg - Builds a bulk urb, sends it off and waits for completion 191 - * @usb_dev: pointer to the usb device to send the message to 192 - * @pipe: endpoint "pipe" to send the message to 193 - * @data: pointer to the data to send 194 - * @len: length in bytes of the data to send 195 - * @actual_length: pointer to a location to put the actual length transferred in bytes 196 - * @timeout: time in msecs to wait for the message to complete before 197 - * timing out (if 0 the wait is forever) 198 - * Context: !in_interrupt () 184 + * usb_bulk_msg - Builds a bulk urb, sends it off and waits for completion 185 + * @usb_dev: pointer to the usb device to send the message to 186 + * @pipe: endpoint "pipe" to send the message to 187 + * @data: pointer to the data to send 188 + * @len: length in bytes of the data to send 189 + * @actual_length: pointer to a location to put the actual length transferred 190 + * in bytes 191 + * @timeout: time in msecs to wait for the message to complete before 192 + * timing out (if 0 the wait is forever) 199 193 * 200 - * This function sends a simple bulk message to a specified endpoint 201 - * and waits for the message to complete, or timeout. 202 - * 203 - * If successful, it returns 0, otherwise a negative error number. 204 - * The number of actual bytes transferred will be stored in the 205 - * actual_length paramater. 194 + * Context: !in_interrupt () 206 195 * 207 - * Don't use this function from within an interrupt context, like a 208 - * bottom half handler. If you need an asynchronous message, or need to 209 - * send a message from within interrupt context, use usb_submit_urb() 210 - * If a thread in your driver uses this call, make sure your disconnect() 211 - * method can wait for it to complete. Since you don't have a handle on 212 - * the URB used, you can't cancel the request. 196 + * This function sends a simple bulk message to a specified endpoint 197 + * and waits for the message to complete, or timeout. 213 198 * 214 - * Because there is no usb_interrupt_msg() and no USBDEVFS_INTERRUPT 215 - * ioctl, users are forced to abuse this routine by using it to submit 216 - * URBs for interrupt endpoints. We will take the liberty of creating 217 - * an interrupt URB (with the default interval) if the target is an 218 - * interrupt endpoint. 199 + * If successful, it returns 0, otherwise a negative error number. The number 200 + * of actual bytes transferred will be stored in the actual_length paramater. 201 + * 202 + * Don't use this function from within an interrupt context, like a bottom half 203 + * handler. If you need an asynchronous message, or need to send a message 204 + * from within interrupt context, use usb_submit_urb() If a thread in your 205 + * driver uses this call, make sure your disconnect() method can wait for it to 206 + * complete. Since you don't have a handle on the URB used, you can't cancel 207 + * the request. 208 + * 209 + * Because there is no usb_interrupt_msg() and no USBDEVFS_INTERRUPT ioctl, 210 + * users are forced to abuse this routine by using it to submit URBs for 211 + * interrupt endpoints. We will take the liberty of creating an interrupt URB 212 + * (with the default interval) if the target is an interrupt endpoint. 219 213 */ 220 - int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe, 221 - void *data, int len, int *actual_length, int timeout) 214 + int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe, 215 + void *data, int len, int *actual_length, int timeout) 222 216 { 223 217 struct urb *urb; 224 218 struct usb_host_endpoint *ep; ··· 244 238 245 239 return usb_start_wait_urb(urb, timeout, actual_length); 246 240 } 241 + EXPORT_SYMBOL_GPL(usb_bulk_msg); 247 242 248 243 /*-------------------------------------------------------------------*/ 249 244 250 - static void sg_clean (struct usb_sg_request *io) 245 + static void sg_clean(struct usb_sg_request *io) 251 246 { 252 247 if (io->urbs) { 253 248 while (io->entries--) 254 - usb_free_urb (io->urbs [io->entries]); 255 - kfree (io->urbs); 249 + usb_free_urb(io->urbs [io->entries]); 250 + kfree(io->urbs); 256 251 io->urbs = NULL; 257 252 } 258 253 if (io->dev->dev.dma_mask != NULL) 259 - usb_buffer_unmap_sg (io->dev, usb_pipein(io->pipe), 260 - io->sg, io->nents); 254 + usb_buffer_unmap_sg(io->dev, usb_pipein(io->pipe), 255 + io->sg, io->nents); 261 256 io->dev = NULL; 262 257 } 263 258 264 - static void sg_complete (struct urb *urb) 259 + static void sg_complete(struct urb *urb) 265 260 { 266 - struct usb_sg_request *io = urb->context; 261 + struct usb_sg_request *io = urb->context; 267 262 int status = urb->status; 268 263 269 - spin_lock (&io->lock); 264 + spin_lock(&io->lock); 270 265 271 266 /* In 2.5 we require hcds' endpoint queues not to progress after fault 272 267 * reports, until the completion callback (this!) returns. That lets ··· 283 276 && (io->status != -ECONNRESET 284 277 || status != -ECONNRESET) 285 278 && urb->actual_length) { 286 - dev_err (io->dev->bus->controller, 279 + dev_err(io->dev->bus->controller, 287 280 "dev %s ep%d%s scatterlist error %d/%d\n", 288 281 io->dev->devpath, 289 282 usb_endpoint_num(&urb->ep->desc), 290 283 usb_urb_dir_in(urb) ? "in" : "out", 291 284 status, io->status); 292 - // BUG (); 285 + /* BUG (); */ 293 286 } 294 287 295 288 if (io->status == 0 && status && status != -ECONNRESET) { ··· 301 294 * unlink pending urbs so they won't rx/tx bad data. 302 295 * careful: unlink can sometimes be synchronous... 303 296 */ 304 - spin_unlock (&io->lock); 297 + spin_unlock(&io->lock); 305 298 for (i = 0, found = 0; i < io->entries; i++) { 306 299 if (!io->urbs [i] || !io->urbs [i]->dev) 307 300 continue; 308 301 if (found) { 309 - retval = usb_unlink_urb (io->urbs [i]); 302 + retval = usb_unlink_urb(io->urbs [i]); 310 303 if (retval != -EINPROGRESS && 311 304 retval != -ENODEV && 312 305 retval != -EBUSY) 313 - dev_err (&io->dev->dev, 306 + dev_err(&io->dev->dev, 314 307 "%s, unlink --> %d\n", 315 308 __FUNCTION__, retval); 316 309 } else if (urb == io->urbs [i]) 317 310 found = 1; 318 311 } 319 - spin_lock (&io->lock); 312 + spin_lock(&io->lock); 320 313 } 321 314 urb->dev = NULL; 322 315 ··· 324 317 io->bytes += urb->actual_length; 325 318 io->count--; 326 319 if (!io->count) 327 - complete (&io->complete); 320 + complete(&io->complete); 328 321 329 - spin_unlock (&io->lock); 322 + spin_unlock(&io->lock); 330 323 } 331 324 332 325 ··· 355 348 * The request may be canceled with usb_sg_cancel(), either before or after 356 349 * usb_sg_wait() is called. 357 350 */ 358 - int usb_sg_init ( 359 - struct usb_sg_request *io, 360 - struct usb_device *dev, 361 - unsigned pipe, 362 - unsigned period, 363 - struct scatterlist *sg, 364 - int nents, 365 - size_t length, 366 - gfp_t mem_flags 367 - ) 351 + int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev, 352 + unsigned pipe, unsigned period, struct scatterlist *sg, 353 + int nents, size_t length, gfp_t mem_flags) 368 354 { 369 - int i; 370 - int urb_flags; 371 - int dma; 355 + int i; 356 + int urb_flags; 357 + int dma; 372 358 373 359 if (!io || !dev || !sg 374 - || usb_pipecontrol (pipe) 375 - || usb_pipeisoc (pipe) 360 + || usb_pipecontrol(pipe) 361 + || usb_pipeisoc(pipe) 376 362 || nents <= 0) 377 363 return -EINVAL; 378 364 379 - spin_lock_init (&io->lock); 365 + spin_lock_init(&io->lock); 380 366 io->dev = dev; 381 367 io->pipe = pipe; 382 368 io->sg = sg; ··· 381 381 dma = (dev->dev.dma_mask != NULL); 382 382 if (dma) 383 383 io->entries = usb_buffer_map_sg(dev, usb_pipein(pipe), 384 - sg, nents); 384 + sg, nents); 385 385 else 386 386 io->entries = nents; 387 387 ··· 390 390 return io->entries; 391 391 392 392 io->count = io->entries; 393 - io->urbs = kmalloc (io->entries * sizeof *io->urbs, mem_flags); 393 + io->urbs = kmalloc(io->entries * sizeof *io->urbs, mem_flags); 394 394 if (!io->urbs) 395 395 goto nomem; 396 396 397 397 urb_flags = URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT; 398 - if (usb_pipein (pipe)) 398 + if (usb_pipein(pipe)) 399 399 urb_flags |= URB_SHORT_NOT_OK; 400 400 401 401 for (i = 0; i < io->entries; i++) { 402 - unsigned len; 402 + unsigned len; 403 403 404 - io->urbs [i] = usb_alloc_urb (0, mem_flags); 405 - if (!io->urbs [i]) { 404 + io->urbs[i] = usb_alloc_urb(0, mem_flags); 405 + if (!io->urbs[i]) { 406 406 io->entries = i; 407 407 goto nomem; 408 408 } 409 409 410 - io->urbs [i]->dev = NULL; 411 - io->urbs [i]->pipe = pipe; 412 - io->urbs [i]->interval = period; 413 - io->urbs [i]->transfer_flags = urb_flags; 410 + io->urbs[i]->dev = NULL; 411 + io->urbs[i]->pipe = pipe; 412 + io->urbs[i]->interval = period; 413 + io->urbs[i]->transfer_flags = urb_flags; 414 414 415 - io->urbs [i]->complete = sg_complete; 416 - io->urbs [i]->context = io; 415 + io->urbs[i]->complete = sg_complete; 416 + io->urbs[i]->context = io; 417 417 418 418 /* 419 419 * Some systems need to revert to PIO when DMA is temporarily ··· 432 432 * to prevent stale pointers and to help spot bugs. 433 433 */ 434 434 if (dma) { 435 - io->urbs [i]->transfer_dma = sg_dma_address (sg + i); 436 - len = sg_dma_len (sg + i); 435 + io->urbs[i]->transfer_dma = sg_dma_address(sg + i); 436 + len = sg_dma_len(sg + i); 437 437 #if defined(CONFIG_HIGHMEM) || defined(CONFIG_GART_IOMMU) 438 438 io->urbs[i]->transfer_buffer = NULL; 439 439 #else ··· 441 441 #endif 442 442 } else { 443 443 /* hc may use _only_ transfer_buffer */ 444 - io->urbs [i]->transfer_buffer = sg_virt(&sg[i]); 445 - len = sg [i].length; 444 + io->urbs[i]->transfer_buffer = sg_virt(&sg[i]); 445 + len = sg[i].length; 446 446 } 447 447 448 448 if (length) { 449 - len = min_t (unsigned, len, length); 449 + len = min_t(unsigned, len, length); 450 450 length -= len; 451 451 if (length == 0) 452 452 io->entries = i + 1; 453 453 } 454 - io->urbs [i]->transfer_buffer_length = len; 454 + io->urbs[i]->transfer_buffer_length = len; 455 455 } 456 - io->urbs [--i]->transfer_flags &= ~URB_NO_INTERRUPT; 456 + io->urbs[--i]->transfer_flags &= ~URB_NO_INTERRUPT; 457 457 458 458 /* transaction state */ 459 459 io->status = 0; 460 460 io->bytes = 0; 461 - init_completion (&io->complete); 461 + init_completion(&io->complete); 462 462 return 0; 463 463 464 464 nomem: 465 - sg_clean (io); 465 + sg_clean(io); 466 466 return -ENOMEM; 467 467 } 468 - 468 + EXPORT_SYMBOL_GPL(usb_sg_init); 469 469 470 470 /** 471 471 * usb_sg_wait - synchronously execute scatter/gather request ··· 506 506 * speed interrupt endpoints, which allow at most one packet per millisecond, 507 507 * of at most 8 or 64 bytes (respectively). 508 508 */ 509 - void usb_sg_wait (struct usb_sg_request *io) 509 + void usb_sg_wait(struct usb_sg_request *io) 510 510 { 511 - int i, entries = io->entries; 511 + int i; 512 + int entries = io->entries; 512 513 513 514 /* queue the urbs. */ 514 - spin_lock_irq (&io->lock); 515 + spin_lock_irq(&io->lock); 515 516 i = 0; 516 517 while (i < entries && !io->status) { 517 - int retval; 518 + int retval; 518 519 519 - io->urbs [i]->dev = io->dev; 520 - retval = usb_submit_urb (io->urbs [i], GFP_ATOMIC); 520 + io->urbs[i]->dev = io->dev; 521 + retval = usb_submit_urb(io->urbs [i], GFP_ATOMIC); 521 522 522 523 /* after we submit, let completions or cancelations fire; 523 524 * we handshake using io->status. 524 525 */ 525 - spin_unlock_irq (&io->lock); 526 + spin_unlock_irq(&io->lock); 526 527 switch (retval) { 527 528 /* maybe we retrying will recover */ 528 - case -ENXIO: // hc didn't queue this one 529 + case -ENXIO: /* hc didn't queue this one */ 529 530 case -EAGAIN: 530 531 case -ENOMEM: 531 532 io->urbs[i]->dev = NULL; 532 533 retval = 0; 533 - yield (); 534 + yield(); 534 535 break; 535 536 536 537 /* no error? continue immediately. ··· 542 541 */ 543 542 case 0: 544 543 ++i; 545 - cpu_relax (); 544 + cpu_relax(); 546 545 break; 547 546 548 547 /* fail any uncompleted urbs */ 549 548 default: 550 - io->urbs [i]->dev = NULL; 551 - io->urbs [i]->status = retval; 552 - dev_dbg (&io->dev->dev, "%s, submit --> %d\n", 549 + io->urbs[i]->dev = NULL; 550 + io->urbs[i]->status = retval; 551 + dev_dbg(&io->dev->dev, "%s, submit --> %d\n", 553 552 __FUNCTION__, retval); 554 - usb_sg_cancel (io); 553 + usb_sg_cancel(io); 555 554 } 556 - spin_lock_irq (&io->lock); 555 + spin_lock_irq(&io->lock); 557 556 if (retval && (io->status == 0 || io->status == -ECONNRESET)) 558 557 io->status = retval; 559 558 } 560 559 io->count -= entries - i; 561 560 if (io->count == 0) 562 - complete (&io->complete); 563 - spin_unlock_irq (&io->lock); 561 + complete(&io->complete); 562 + spin_unlock_irq(&io->lock); 564 563 565 564 /* OK, yes, this could be packaged as non-blocking. 566 565 * So could the submit loop above ... but it's easier to 567 566 * solve neither problem than to solve both! 568 567 */ 569 - wait_for_completion (&io->complete); 568 + wait_for_completion(&io->complete); 570 569 571 - sg_clean (io); 570 + sg_clean(io); 572 571 } 572 + EXPORT_SYMBOL_GPL(usb_sg_wait); 573 573 574 574 /** 575 575 * usb_sg_cancel - stop scatter/gather i/o issued by usb_sg_wait() ··· 580 578 * It can also prevents one initialized by usb_sg_init() from starting, 581 579 * so that call just frees resources allocated to the request. 582 580 */ 583 - void usb_sg_cancel (struct usb_sg_request *io) 581 + void usb_sg_cancel(struct usb_sg_request *io) 584 582 { 585 - unsigned long flags; 583 + unsigned long flags; 586 584 587 - spin_lock_irqsave (&io->lock, flags); 585 + spin_lock_irqsave(&io->lock, flags); 588 586 589 587 /* shut everything down, if it didn't already */ 590 588 if (!io->status) { 591 - int i; 589 + int i; 592 590 593 591 io->status = -ECONNRESET; 594 - spin_unlock (&io->lock); 592 + spin_unlock(&io->lock); 595 593 for (i = 0; i < io->entries; i++) { 596 - int retval; 594 + int retval; 597 595 598 596 if (!io->urbs [i]->dev) 599 597 continue; 600 - retval = usb_unlink_urb (io->urbs [i]); 598 + retval = usb_unlink_urb(io->urbs [i]); 601 599 if (retval != -EINPROGRESS && retval != -EBUSY) 602 - dev_warn (&io->dev->dev, "%s, unlink --> %d\n", 600 + dev_warn(&io->dev->dev, "%s, unlink --> %d\n", 603 601 __FUNCTION__, retval); 604 602 } 605 - spin_lock (&io->lock); 603 + spin_lock(&io->lock); 606 604 } 607 - spin_unlock_irqrestore (&io->lock, flags); 605 + spin_unlock_irqrestore(&io->lock, flags); 608 606 } 607 + EXPORT_SYMBOL_GPL(usb_sg_cancel); 609 608 610 609 /*-------------------------------------------------------------------*/ 611 610 ··· 632 629 * Returns the number of bytes received on success, or else the status code 633 630 * returned by the underlying usb_control_msg() call. 634 631 */ 635 - int usb_get_descriptor(struct usb_device *dev, unsigned char type, unsigned char index, void *buf, int size) 632 + int usb_get_descriptor(struct usb_device *dev, unsigned char type, 633 + unsigned char index, void *buf, int size) 636 634 { 637 635 int i; 638 636 int result; 639 - 640 - memset(buf,0,size); // Make sure we parse really received data 637 + 638 + memset(buf, 0, size); /* Make sure we parse really received data */ 641 639 642 640 for (i = 0; i < 3; ++i) { 643 641 /* retry on length 0 or error; some devices are flakey */ ··· 656 652 } 657 653 return result; 658 654 } 655 + EXPORT_SYMBOL_GPL(usb_get_descriptor); 659 656 660 657 /** 661 658 * usb_get_string - gets a string descriptor ··· 713 708 } 714 709 715 710 static int usb_string_sub(struct usb_device *dev, unsigned int langid, 716 - unsigned int index, unsigned char *buf) 711 + unsigned int index, unsigned char *buf) 717 712 { 718 713 int rc; 719 714 ··· 756 751 * @buf: where to put the string 757 752 * @size: how big is "buf"? 758 753 * Context: !in_interrupt () 759 - * 754 + * 760 755 * This converts the UTF-16LE encoded strings returned by devices, from 761 756 * usb_get_string_descriptor(), to null-terminated ISO-8859-1 encoded ones 762 757 * that are more usable in most kernel contexts. Note that all characters ··· 792 787 if (!dev->have_langid) { 793 788 err = usb_string_sub(dev, 0, 0, tbuf); 794 789 if (err < 0) { 795 - dev_err (&dev->dev, 790 + dev_err(&dev->dev, 796 791 "string descriptor 0 read error: %d\n", 797 792 err); 798 793 goto errout; 799 794 } else if (err < 4) { 800 - dev_err (&dev->dev, "string descriptor 0 too short\n"); 795 + dev_err(&dev->dev, "string descriptor 0 too short\n"); 801 796 err = -EINVAL; 802 797 goto errout; 803 798 } else { 804 799 dev->have_langid = 1; 805 - dev->string_langid = tbuf[2] | (tbuf[3]<< 8); 806 - /* always use the first langid listed */ 807 - dev_dbg (&dev->dev, "default language 0x%04x\n", 800 + dev->string_langid = tbuf[2] | (tbuf[3] << 8); 801 + /* always use the first langid listed */ 802 + dev_dbg(&dev->dev, "default language 0x%04x\n", 808 803 dev->string_langid); 809 804 } 810 805 } 811 - 806 + 812 807 err = usb_string_sub(dev, dev->string_langid, index, tbuf); 813 808 if (err < 0) 814 809 goto errout; ··· 826 821 err = idx; 827 822 828 823 if (tbuf[1] != USB_DT_STRING) 829 - dev_dbg(&dev->dev, "wrong descriptor type %02x for string %d (\"%s\")\n", tbuf[1], index, buf); 824 + dev_dbg(&dev->dev, 825 + "wrong descriptor type %02x for string %d (\"%s\")\n", 826 + tbuf[1], index, buf); 830 827 831 828 errout: 832 829 kfree(tbuf); 833 830 return err; 834 831 } 832 + EXPORT_SYMBOL_GPL(usb_string); 835 833 836 834 /** 837 835 * usb_cache_string - read a string descriptor and cache it for later use ··· 850 842 char *smallbuf = NULL; 851 843 int len; 852 844 853 - if (index > 0 && (buf = kmalloc(256, GFP_KERNEL)) != NULL) { 854 - if ((len = usb_string(udev, index, buf, 256)) > 0) { 855 - if ((smallbuf = kmalloc(++len, GFP_KERNEL)) == NULL) 845 + if (index <= 0) 846 + return NULL; 847 + 848 + buf = kmalloc(256, GFP_KERNEL); 849 + if (buf) { 850 + len = usb_string(udev, index, buf, 256); 851 + if (len > 0) { 852 + smallbuf = kmalloc(++len, GFP_KERNEL); 853 + if (!smallbuf) 856 854 return buf; 857 855 memcpy(smallbuf, buf, len); 858 856 } ··· 897 883 return -ENOMEM; 898 884 899 885 ret = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, size); 900 - if (ret >= 0) 886 + if (ret >= 0) 901 887 memcpy(&dev->descriptor, desc, size); 902 888 kfree(desc); 903 889 return ret; ··· 941 927 kfree(status); 942 928 return ret; 943 929 } 930 + EXPORT_SYMBOL_GPL(usb_get_status); 944 931 945 932 /** 946 933 * usb_clear_halt - tells device to clear endpoint halt/stall condition ··· 970 955 { 971 956 int result; 972 957 int endp = usb_pipeendpoint(pipe); 973 - 974 - if (usb_pipein (pipe)) 958 + 959 + if (usb_pipein(pipe)) 975 960 endp |= USB_DIR_IN; 976 961 977 962 /* we don't care if it wasn't halted first. in fact some devices ··· 1000 985 1001 986 return 0; 1002 987 } 988 + EXPORT_SYMBOL_GPL(usb_clear_halt); 1003 989 1004 990 /** 1005 991 * usb_disable_endpoint -- Disable an endpoint by address ··· 1054 1038 } 1055 1039 } 1056 1040 1057 - /* 1041 + /** 1058 1042 * usb_disable_device - Disable all the endpoints for a USB device 1059 1043 * @dev: the device whose endpoints are being disabled 1060 1044 * @skip_ep0: 0 to disable endpoint 0, 1 to skip it. ··· 1069 1053 int i; 1070 1054 1071 1055 dev_dbg(&dev->dev, "%s nuking %s URBs\n", __FUNCTION__, 1072 - skip_ep0 ? "non-ep0" : "all"); 1056 + skip_ep0 ? "non-ep0" : "all"); 1073 1057 for (i = skip_ep0; i < 16; ++i) { 1074 1058 usb_disable_endpoint(dev, i); 1075 1059 usb_disable_endpoint(dev, i + USB_DIR_IN); ··· 1087 1071 interface = dev->actconfig->interface[i]; 1088 1072 if (!device_is_registered(&interface->dev)) 1089 1073 continue; 1090 - dev_dbg (&dev->dev, "unregistering interface %s\n", 1074 + dev_dbg(&dev->dev, "unregistering interface %s\n", 1091 1075 interface->dev.bus_id); 1092 1076 usb_remove_sysfs_intf_files(interface); 1093 - device_del (&interface->dev); 1077 + device_del(&interface->dev); 1094 1078 } 1095 1079 1096 1080 /* Now that the interfaces are unbound, nobody should 1097 1081 * try to access them. 1098 1082 */ 1099 1083 for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { 1100 - put_device (&dev->actconfig->interface[i]->dev); 1084 + put_device(&dev->actconfig->interface[i]->dev); 1101 1085 dev->actconfig->interface[i] = NULL; 1102 1086 } 1103 1087 dev->actconfig = NULL; ··· 1106 1090 } 1107 1091 } 1108 1092 1109 - 1110 - /* 1093 + /** 1111 1094 * usb_enable_endpoint - Enable an endpoint for USB communications 1112 1095 * @dev: the device whose interface is being enabled 1113 1096 * @ep: the endpoint ··· 1131 1116 ep->enabled = 1; 1132 1117 } 1133 1118 1134 - /* 1119 + /** 1135 1120 * usb_enable_interface - Enable all the endpoints for an interface 1136 1121 * @dev: the device whose interface is being enabled 1137 1122 * @intf: pointer to the interface descriptor ··· 1187 1172 struct usb_host_interface *alt; 1188 1173 int ret; 1189 1174 int manual = 0; 1175 + unsigned int epaddr; 1176 + unsigned int pipe; 1190 1177 1191 1178 if (dev->state == USB_STATE_SUSPENDED) 1192 1179 return -EHOSTUNREACH; ··· 1243 1226 int i; 1244 1227 1245 1228 for (i = 0; i < alt->desc.bNumEndpoints; i++) { 1246 - unsigned int epaddr = 1247 - alt->endpoint[i].desc.bEndpointAddress; 1248 - unsigned int pipe = 1249 - __create_pipe(dev, USB_ENDPOINT_NUMBER_MASK & epaddr) 1250 - | (usb_endpoint_out(epaddr) ? USB_DIR_OUT : USB_DIR_IN); 1229 + epaddr = alt->endpoint[i].desc.bEndpointAddress; 1230 + pipe = __create_pipe(dev, 1231 + USB_ENDPOINT_NUMBER_MASK & epaddr) | 1232 + (usb_endpoint_out(epaddr) ? 1233 + USB_DIR_OUT : USB_DIR_IN); 1251 1234 1252 1235 usb_clear_halt(dev, pipe); 1253 1236 } ··· 1270 1253 1271 1254 return 0; 1272 1255 } 1256 + EXPORT_SYMBOL_GPL(usb_set_interface); 1273 1257 1274 1258 /** 1275 1259 * usb_reset_configuration - lightweight device reset ··· 1346 1328 } 1347 1329 return 0; 1348 1330 } 1331 + EXPORT_SYMBOL_GPL(usb_reset_configuration); 1349 1332 1350 1333 static void usb_release_interface(struct device *dev) 1351 1334 { ··· 1376 1357 return -ENOMEM; 1377 1358 1378 1359 if (add_uevent_var(env, 1379 - "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X", 1360 + "MODALIAS=usb:" 1361 + "v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X", 1380 1362 le16_to_cpu(usb_dev->descriptor.idVendor), 1381 1363 le16_to_cpu(usb_dev->descriptor.idProduct), 1382 1364 le16_to_cpu(usb_dev->descriptor.bcdDevice), ··· 1407 1387 }; 1408 1388 1409 1389 static struct usb_interface_assoc_descriptor *find_iad(struct usb_device *dev, 1410 - struct usb_host_config *config, 1411 - u8 inum) 1390 + struct usb_host_config *config, 1391 + u8 inum) 1412 1392 { 1413 1393 struct usb_interface_assoc_descriptor *retval = NULL; 1414 1394 struct usb_interface_assoc_descriptor *intf_assoc; ··· 1434 1414 1435 1415 return retval; 1436 1416 } 1437 - 1438 1417 1439 1418 /* 1440 1419 * usb_set_configuration - Makes a particular device setting be current ··· 1552 1533 * getting rid of old interfaces means unbinding their drivers. 1553 1534 */ 1554 1535 if (dev->state != USB_STATE_ADDRESS) 1555 - usb_disable_device (dev, 1); // Skip ep0 1536 + usb_disable_device(dev, 1); /* Skip ep0 */ 1556 1537 1557 - if ((ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1558 - USB_REQ_SET_CONFIGURATION, 0, configuration, 0, 1559 - NULL, 0, USB_CTRL_SET_TIMEOUT)) < 0) { 1560 - 1538 + ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1539 + USB_REQ_SET_CONFIGURATION, 0, configuration, 0, 1540 + NULL, 0, USB_CTRL_SET_TIMEOUT); 1541 + if (ret < 0) { 1561 1542 /* All the old state is gone, so what else can we do? 1562 1543 * The device is probably useless now anyway. 1563 1544 */ ··· 1604 1585 intf->dev.bus = &usb_bus_type; 1605 1586 intf->dev.type = &usb_if_device_type; 1606 1587 intf->dev.dma_mask = dev->dev.dma_mask; 1607 - device_initialize (&intf->dev); 1588 + device_initialize(&intf->dev); 1608 1589 mark_quiesced(intf); 1609 - sprintf (&intf->dev.bus_id[0], "%d-%s:%d.%d", 1610 - dev->bus->busnum, dev->devpath, 1611 - configuration, alt->desc.bInterfaceNumber); 1590 + sprintf(&intf->dev.bus_id[0], "%d-%s:%d.%d", 1591 + dev->bus->busnum, dev->devpath, 1592 + configuration, alt->desc.bInterfaceNumber); 1612 1593 } 1613 1594 kfree(new_interfaces); 1614 1595 ··· 1624 1605 for (i = 0; i < nintf; ++i) { 1625 1606 struct usb_interface *intf = cp->interface[i]; 1626 1607 1627 - dev_dbg (&dev->dev, 1608 + dev_dbg(&dev->dev, 1628 1609 "adding %s (config #%d, interface %d)\n", 1629 1610 intf->dev.bus_id, configuration, 1630 1611 intf->cur_altsetting->desc.bInterfaceNumber); 1631 - ret = device_add (&intf->dev); 1612 + ret = device_add(&intf->dev); 1632 1613 if (ret != 0) { 1633 1614 dev_err(&dev->dev, "device_add(%s) --> %d\n", 1634 1615 intf->dev.bus_id, ret); ··· 1696 1677 return 0; 1697 1678 } 1698 1679 EXPORT_SYMBOL_GPL(usb_driver_set_configuration); 1699 - 1700 - // synchronous request completion model 1701 - EXPORT_SYMBOL(usb_control_msg); 1702 - EXPORT_SYMBOL(usb_bulk_msg); 1703 - 1704 - EXPORT_SYMBOL(usb_sg_init); 1705 - EXPORT_SYMBOL(usb_sg_cancel); 1706 - EXPORT_SYMBOL(usb_sg_wait); 1707 - 1708 - // synchronous control message convenience routines 1709 - EXPORT_SYMBOL(usb_get_descriptor); 1710 - EXPORT_SYMBOL(usb_get_status); 1711 - EXPORT_SYMBOL(usb_string); 1712 - 1713 - // synchronous calls that also maintain usbcore state 1714 - EXPORT_SYMBOL(usb_clear_halt); 1715 - EXPORT_SYMBOL(usb_reset_configuration); 1716 - EXPORT_SYMBOL(usb_set_interface); 1717 -
+1 -1
drivers/usb/core/notify.c
··· 33 33 * usb_unregister_notify - unregister a notifier callback 34 34 * @nb: pointer to the notifier block for the callback events. 35 35 * 36 - * usb_register_notifier() must have been previously called for this function 36 + * usb_register_notify() must have been previously called for this function 37 37 * to work properly. 38 38 */ 39 39 void usb_unregister_notify(struct notifier_block *nb)
+3 -3
drivers/usb/core/otg_whitelist.h
··· 14 14 * mostly use of USB_DEVICE() or USB_DEVICE_VER() entries.. 15 15 * 16 16 * YOU _SHOULD_ CHANGE THIS LIST TO MATCH YOUR PRODUCT AND ITS TESTING! 17 - */ 17 + */ 18 18 19 19 static struct usb_device_id whitelist_table [] = { 20 20 ··· 55 55 return 1; 56 56 57 57 /* HNP test device is _never_ targeted (see OTG spec 6.6.6) */ 58 - if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a && 58 + if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a && 59 59 le16_to_cpu(dev->descriptor.idProduct) == 0xbadd)) 60 60 return 0; 61 61 ··· 86 86 continue; 87 87 88 88 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) && 89 - (id->bDeviceSubClass!= dev->descriptor.bDeviceSubClass)) 89 + (id->bDeviceSubClass != dev->descriptor.bDeviceSubClass)) 90 90 continue; 91 91 92 92 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) &&
+59 -10
drivers/usb/core/sysfs.c
··· 72 72 return (value < 0) ? value : count; 73 73 } 74 74 75 - static DEVICE_ATTR(bConfigurationValue, S_IRUGO | S_IWUSR, 75 + static DEVICE_ATTR(bConfigurationValue, S_IRUGO | S_IWUSR, 76 76 show_bConfigurationValue, set_bConfigurationValue); 77 77 78 78 /* String fields */ ··· 249 249 #ifdef CONFIG_USB_SUSPEND 250 250 251 251 static ssize_t 252 + show_connected_duration(struct device *dev, struct device_attribute *attr, 253 + char *buf) 254 + { 255 + struct usb_device *udev = to_usb_device(dev); 256 + 257 + return sprintf(buf, "%u\n", 258 + jiffies_to_msecs(jiffies - udev->connect_time)); 259 + } 260 + 261 + static DEVICE_ATTR(connected_duration, S_IRUGO, show_connected_duration, NULL); 262 + 263 + /* 264 + * If the device is resumed, the last time the device was suspended has 265 + * been pre-subtracted from active_duration. We add the current time to 266 + * get the duration that the device was actually active. 267 + * 268 + * If the device is suspended, the active_duration is up-to-date. 269 + */ 270 + static ssize_t 271 + show_active_duration(struct device *dev, struct device_attribute *attr, 272 + char *buf) 273 + { 274 + struct usb_device *udev = to_usb_device(dev); 275 + int duration; 276 + 277 + if (udev->state != USB_STATE_SUSPENDED) 278 + duration = jiffies_to_msecs(jiffies + udev->active_duration); 279 + else 280 + duration = jiffies_to_msecs(udev->active_duration); 281 + return sprintf(buf, "%u\n", duration); 282 + } 283 + 284 + static DEVICE_ATTR(active_duration, S_IRUGO, show_active_duration, NULL); 285 + 286 + static ssize_t 252 287 show_autosuspend(struct device *dev, struct device_attribute *attr, char *buf) 253 288 { 254 289 struct usb_device *udev = to_usb_device(dev); ··· 400 365 rc = sysfs_add_file_to_group(&dev->kobj, 401 366 &dev_attr_level.attr, 402 367 power_group); 368 + if (rc == 0) 369 + rc = sysfs_add_file_to_group(&dev->kobj, 370 + &dev_attr_connected_duration.attr, 371 + power_group); 372 + if (rc == 0) 373 + rc = sysfs_add_file_to_group(&dev->kobj, 374 + &dev_attr_active_duration.attr, 375 + power_group); 403 376 } 404 377 return rc; 405 378 } 406 379 407 380 static void remove_power_attributes(struct device *dev) 408 381 { 382 + sysfs_remove_file_from_group(&dev->kobj, 383 + &dev_attr_active_duration.attr, 384 + power_group); 385 + sysfs_remove_file_from_group(&dev->kobj, 386 + &dev_attr_connected_duration.attr, 387 + power_group); 409 388 sysfs_remove_file_from_group(&dev->kobj, 410 389 &dev_attr_level.attr, 411 390 power_group); ··· 650 601 /* Interface Accociation Descriptor fields */ 651 602 #define usb_intf_assoc_attr(field, format_string) \ 652 603 static ssize_t \ 653 - show_iad_##field (struct device *dev, struct device_attribute *attr, \ 604 + show_iad_##field(struct device *dev, struct device_attribute *attr, \ 654 605 char *buf) \ 655 606 { \ 656 - struct usb_interface *intf = to_usb_interface (dev); \ 607 + struct usb_interface *intf = to_usb_interface(dev); \ 657 608 \ 658 - return sprintf (buf, format_string, \ 659 - intf->intf_assoc->field); \ 609 + return sprintf(buf, format_string, \ 610 + intf->intf_assoc->field); \ 660 611 } \ 661 612 static DEVICE_ATTR(iad_##field, S_IRUGO, show_iad_##field, NULL); 662 613 663 - usb_intf_assoc_attr (bFirstInterface, "%02x\n") 664 - usb_intf_assoc_attr (bInterfaceCount, "%02d\n") 665 - usb_intf_assoc_attr (bFunctionClass, "%02x\n") 666 - usb_intf_assoc_attr (bFunctionSubClass, "%02x\n") 667 - usb_intf_assoc_attr (bFunctionProtocol, "%02x\n") 614 + usb_intf_assoc_attr(bFirstInterface, "%02x\n") 615 + usb_intf_assoc_attr(bInterfaceCount, "%02d\n") 616 + usb_intf_assoc_attr(bFunctionClass, "%02x\n") 617 + usb_intf_assoc_attr(bFunctionSubClass, "%02x\n") 618 + usb_intf_assoc_attr(bFunctionProtocol, "%02x\n") 668 619 669 620 /* Interface fields */ 670 621 #define usb_intf_attr(field, format_string) \
+19 -18
drivers/usb/core/urb.c
··· 42 42 INIT_LIST_HEAD(&urb->anchor_list); 43 43 } 44 44 } 45 + EXPORT_SYMBOL_GPL(usb_init_urb); 45 46 46 47 /** 47 48 * usb_alloc_urb - creates a new urb for a USB driver to use ··· 74 73 usb_init_urb(urb); 75 74 return urb; 76 75 } 76 + EXPORT_SYMBOL_GPL(usb_alloc_urb); 77 77 78 78 /** 79 79 * usb_free_urb - frees the memory used by a urb when all users of it are finished ··· 91 89 if (urb) 92 90 kref_put(&urb->kref, urb_destroy); 93 91 } 92 + EXPORT_SYMBOL_GPL(usb_free_urb); 94 93 95 94 /** 96 95 * usb_get_urb - increments the reference count of the urb ··· 103 100 * 104 101 * A pointer to the urb with the incremented reference counter is returned. 105 102 */ 106 - struct urb * usb_get_urb(struct urb *urb) 103 + struct urb *usb_get_urb(struct urb *urb) 107 104 { 108 105 if (urb) 109 106 kref_get(&urb->kref); 110 107 return urb; 111 108 } 109 + EXPORT_SYMBOL_GPL(usb_get_urb); 112 110 113 111 /** 114 112 * usb_anchor_urb - anchors an URB while it is processed ··· 176 172 * describing that request to the USB subsystem. Request completion will 177 173 * be indicated later, asynchronously, by calling the completion handler. 178 174 * The three types of completion are success, error, and unlink 179 - * (a software-induced fault, also called "request cancellation"). 175 + * (a software-induced fault, also called "request cancellation"). 180 176 * 181 177 * URBs may be submitted in interrupt context. 182 178 * ··· 259 255 * semaphores), or 260 256 * (c) current->state != TASK_RUNNING, this is the case only after 261 257 * you've changed it. 262 - * 258 + * 263 259 * GFP_NOIO is used in the block io path and error handling of storage 264 260 * devices. 265 261 * ··· 288 284 289 285 if (!urb || urb->hcpriv || !urb->complete) 290 286 return -EINVAL; 291 - if (!(dev = urb->dev) || dev->state < USB_STATE_DEFAULT) 287 + dev = urb->dev; 288 + if ((!dev) || (dev->state < USB_STATE_DEFAULT)) 292 289 return -ENODEV; 293 290 294 291 /* For now, get the endpoint from the pipe. Eventually drivers ··· 352 347 max *= mult; 353 348 } 354 349 355 - if (urb->number_of_packets <= 0) 350 + if (urb->number_of_packets <= 0) 356 351 return -EINVAL; 357 352 for (n = 0; n < urb->number_of_packets; n++) { 358 353 len = urb->iso_frame_desc[n].length; 359 - if (len < 0 || len > max) 354 + if (len < 0 || len > max) 360 355 return -EMSGSIZE; 361 356 urb->iso_frame_desc[n].status = -EXDEV; 362 357 urb->iso_frame_desc[n].actual_length = 0; ··· 421 416 /* too big? */ 422 417 switch (dev->speed) { 423 418 case USB_SPEED_HIGH: /* units are microframes */ 424 - // NOTE usb handles 2^15 419 + /* NOTE usb handles 2^15 */ 425 420 if (urb->interval > (1024 * 8)) 426 421 urb->interval = 1024 * 8; 427 422 max = 1024 * 8; ··· 431 426 if (xfertype == USB_ENDPOINT_XFER_INT) { 432 427 if (urb->interval > 255) 433 428 return -EINVAL; 434 - // NOTE ohci only handles up to 32 429 + /* NOTE ohci only handles up to 32 */ 435 430 max = 128; 436 431 } else { 437 432 if (urb->interval > 1024) 438 433 urb->interval = 1024; 439 - // NOTE usb and ohci handle up to 2^15 434 + /* NOTE usb and ohci handle up to 2^15 */ 440 435 max = 1024; 441 436 } 442 437 break; ··· 449 444 450 445 return usb_hcd_submit_urb(urb, mem_flags); 451 446 } 447 + EXPORT_SYMBOL_GPL(usb_submit_urb); 452 448 453 449 /*-------------------------------------------------------------------*/ 454 450 ··· 520 514 return -EIDRM; 521 515 return usb_hcd_unlink_urb(urb, -ECONNRESET); 522 516 } 517 + EXPORT_SYMBOL_GPL(usb_unlink_urb); 523 518 524 519 /** 525 520 * usb_kill_urb - cancel a transfer request and wait for it to finish ··· 560 553 --urb->reject; 561 554 mutex_unlock(&reject_mutex); 562 555 } 556 + EXPORT_SYMBOL_GPL(usb_kill_urb); 563 557 564 558 /** 565 559 * usb_kill_anchored_urbs - cancel transfer requests en masse ··· 575 567 576 568 spin_lock_irq(&anchor->lock); 577 569 while (!list_empty(&anchor->urb_list)) { 578 - victim = list_entry(anchor->urb_list.prev, struct urb, anchor_list); 570 + victim = list_entry(anchor->urb_list.prev, struct urb, 571 + anchor_list); 579 572 /* we must make sure the URB isn't freed before we kill it*/ 580 573 usb_get_urb(victim); 581 574 spin_unlock_irq(&anchor->lock); ··· 604 595 msecs_to_jiffies(timeout)); 605 596 } 606 597 EXPORT_SYMBOL_GPL(usb_wait_anchor_empty_timeout); 607 - 608 - EXPORT_SYMBOL(usb_init_urb); 609 - EXPORT_SYMBOL(usb_alloc_urb); 610 - EXPORT_SYMBOL(usb_free_urb); 611 - EXPORT_SYMBOL(usb_get_urb); 612 - EXPORT_SYMBOL(usb_submit_urb); 613 - EXPORT_SYMBOL(usb_unlink_urb); 614 - EXPORT_SYMBOL(usb_kill_urb);
+44 -73
drivers/usb/core/usb.c
··· 96 96 97 97 return NULL; 98 98 } 99 + EXPORT_SYMBOL_GPL(usb_ifnum_to_if); 99 100 100 101 /** 101 102 * usb_altnum_to_altsetting - get the altsetting structure with a given ··· 116 115 * Don't call this function unless you are bound to the intf interface 117 116 * or you have locked the device! 118 117 */ 119 - struct usb_host_interface *usb_altnum_to_altsetting(const struct usb_interface *intf, 120 - unsigned int altnum) 118 + struct usb_host_interface *usb_altnum_to_altsetting( 119 + const struct usb_interface *intf, 120 + unsigned int altnum) 121 121 { 122 122 int i; 123 123 ··· 128 126 } 129 127 return NULL; 130 128 } 129 + EXPORT_SYMBOL_GPL(usb_altnum_to_altsetting); 131 130 132 131 struct find_interface_arg { 133 132 int minor; 134 133 struct usb_interface *interface; 135 134 }; 136 135 137 - static int __find_interface(struct device * dev, void * data) 136 + static int __find_interface(struct device *dev, void *data) 138 137 { 139 138 struct find_interface_arg *arg = data; 140 139 struct usb_interface *intf; ··· 157 154 * @drv: the driver whose current configuration is considered 158 155 * @minor: the minor number of the desired device 159 156 * 160 - * This walks the driver device list and returns a pointer to the interface 157 + * This walks the driver device list and returns a pointer to the interface 161 158 * with the matching minor. Note, this only works for devices that share the 162 159 * USB major number. 163 160 */ ··· 173 170 __find_interface); 174 171 return argb.interface; 175 172 } 173 + EXPORT_SYMBOL_GPL(usb_find_interface); 176 174 177 175 /** 178 176 * usb_release_dev - free a usb device structure when all users of it are finished. ··· 234 230 * singlethreaded. Its job doesn't justify running on more 235 231 * than one CPU. 236 232 */ 237 - ksuspend_usb_wq = create_freezeable_workqueue("ksuspend_usbd"); 233 + ksuspend_usb_wq = create_singlethread_workqueue("ksuspend_usbd"); 238 234 if (!ksuspend_usb_wq) 239 235 return -ENOMEM; 240 236 return 0; ··· 273 269 * 274 270 * This call may not be used in a non-sleeping context. 275 271 */ 276 - struct usb_device * 277 - usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1) 272 + struct usb_device *usb_alloc_dev(struct usb_device *parent, 273 + struct usb_bus *bus, unsigned port1) 278 274 { 279 275 struct usb_device *dev; 280 276 struct usb_hcd *usb_hcd = container_of(bus, struct usb_hcd, self); ··· 343 339 mutex_init(&dev->pm_mutex); 344 340 INIT_DELAYED_WORK(&dev->autosuspend, usb_autosuspend_work); 345 341 dev->autosuspend_delay = usb_autosuspend_delay * HZ; 342 + dev->connect_time = jiffies; 343 + dev->active_duration = -jiffies; 346 344 #endif 347 345 if (root_hub) /* Root hub always ok [and always wired] */ 348 346 dev->authorized = 1; ··· 373 367 get_device(&dev->dev); 374 368 return dev; 375 369 } 370 + EXPORT_SYMBOL_GPL(usb_get_dev); 376 371 377 372 /** 378 373 * usb_put_dev - release a use of the usb device structure ··· 387 380 if (dev) 388 381 put_device(&dev->dev); 389 382 } 383 + EXPORT_SYMBOL_GPL(usb_put_dev); 390 384 391 385 /** 392 386 * usb_get_intf - increments the reference count of the usb interface structure ··· 408 400 get_device(&intf->dev); 409 401 return intf; 410 402 } 403 + EXPORT_SYMBOL_GPL(usb_get_intf); 411 404 412 405 /** 413 406 * usb_put_intf - release a use of the usb interface structure ··· 423 414 if (intf) 424 415 put_device(&intf->dev); 425 416 } 426 - 417 + EXPORT_SYMBOL_GPL(usb_put_intf); 427 418 428 419 /* USB device locking 429 420 * ··· 470 461 return -EHOSTUNREACH; 471 462 if (iface) { 472 463 switch (iface->condition) { 473 - case USB_INTERFACE_BINDING: 464 + case USB_INTERFACE_BINDING: 474 465 return 0; 475 - case USB_INTERFACE_BOUND: 466 + case USB_INTERFACE_BOUND: 476 467 break; 477 - default: 468 + default: 478 469 return -EINTR; 479 470 } 480 471 } ··· 496 487 } 497 488 return 1; 498 489 } 499 - 490 + EXPORT_SYMBOL_GPL(usb_lock_device_for_reset); 500 491 501 492 static struct usb_device *match_device(struct usb_device *dev, 502 493 u16 vendor_id, u16 product_id) ··· 549 540 struct list_head *buslist; 550 541 struct usb_bus *bus; 551 542 struct usb_device *dev = NULL; 552 - 543 + 553 544 mutex_lock(&usb_bus_list_lock); 554 545 for (buslist = usb_bus_list.next; 555 - buslist != &usb_bus_list; 546 + buslist != &usb_bus_list; 556 547 buslist = buslist->next) { 557 548 bus = container_of(buslist, struct usb_bus, bus_list); 558 549 if (!bus->root_hub) ··· 585 576 { 586 577 return usb_hcd_get_frame_number(dev); 587 578 } 579 + EXPORT_SYMBOL_GPL(usb_get_current_frame_number); 588 580 589 581 /*-------------------------------------------------------------------*/ 590 582 /* ··· 594 584 */ 595 585 596 586 int __usb_get_extra_descriptor(char *buffer, unsigned size, 597 - unsigned char type, void **ptr) 587 + unsigned char type, void **ptr) 598 588 { 599 589 struct usb_descriptor_header *header; 600 590 ··· 605 595 printk(KERN_ERR 606 596 "%s: bogus descriptor, type %d length %d\n", 607 597 usbcore_name, 608 - header->bDescriptorType, 598 + header->bDescriptorType, 609 599 header->bLength); 610 600 return -1; 611 601 } ··· 620 610 } 621 611 return -1; 622 612 } 613 + EXPORT_SYMBOL_GPL(__usb_get_extra_descriptor); 623 614 624 615 /** 625 616 * usb_buffer_alloc - allocate dma-consistent buffer for URB_NO_xxx_DMA_MAP ··· 644 633 * 645 634 * When the buffer is no longer used, free it with usb_buffer_free(). 646 635 */ 647 - void *usb_buffer_alloc( 648 - struct usb_device *dev, 649 - size_t size, 650 - gfp_t mem_flags, 651 - dma_addr_t *dma 652 - ) 636 + void *usb_buffer_alloc(struct usb_device *dev, size_t size, gfp_t mem_flags, 637 + dma_addr_t *dma) 653 638 { 654 639 if (!dev || !dev->bus) 655 640 return NULL; 656 641 return hcd_buffer_alloc(dev->bus, size, mem_flags, dma); 657 642 } 643 + EXPORT_SYMBOL_GPL(usb_buffer_alloc); 658 644 659 645 /** 660 646 * usb_buffer_free - free memory allocated with usb_buffer_alloc() ··· 664 656 * been allocated using usb_buffer_alloc(), and the parameters must match 665 657 * those provided in that allocation request. 666 658 */ 667 - void usb_buffer_free( 668 - struct usb_device *dev, 669 - size_t size, 670 - void *addr, 671 - dma_addr_t dma 672 - ) 659 + void usb_buffer_free(struct usb_device *dev, size_t size, void *addr, 660 + dma_addr_t dma) 673 661 { 674 662 if (!dev || !dev->bus) 675 663 return; ··· 673 669 return; 674 670 hcd_buffer_free(dev->bus, size, addr, dma); 675 671 } 672 + EXPORT_SYMBOL_GPL(usb_buffer_free); 676 673 677 674 /** 678 675 * usb_buffer_map - create DMA mapping(s) for an urb ··· 713 708 urb->setup_packet, 714 709 sizeof(struct usb_ctrlrequest), 715 710 DMA_TO_DEVICE); 716 - // FIXME generic api broken like pci, can't report errors 717 - // if (urb->transfer_dma == DMA_ADDR_INVALID) return 0; 711 + /* FIXME generic api broken like pci, can't report errors */ 712 + /* if (urb->transfer_dma == DMA_ADDR_INVALID) return 0; */ 718 713 } else 719 714 urb->transfer_dma = ~0; 720 715 urb->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP 721 716 | URB_NO_SETUP_DMA_MAP); 722 717 return urb; 723 718 } 719 + EXPORT_SYMBOL_GPL(usb_buffer_map); 724 720 #endif /* 0 */ 725 721 726 722 /* XXX DISABLED, no users currently. If you wish to re-enable this ··· 759 753 DMA_TO_DEVICE); 760 754 } 761 755 } 756 + EXPORT_SYMBOL_GPL(usb_buffer_dmasync); 762 757 #endif 763 758 764 759 /** ··· 795 788 urb->transfer_flags &= ~(URB_NO_TRANSFER_DMA_MAP 796 789 | URB_NO_SETUP_DMA_MAP); 797 790 } 791 + EXPORT_SYMBOL_GPL(usb_buffer_unmap); 798 792 #endif /* 0 */ 799 793 800 794 /** ··· 836 828 || !controller->dma_mask) 837 829 return -1; 838 830 839 - // FIXME generic api broken like pci, can't report errors 831 + /* FIXME generic api broken like pci, can't report errors */ 840 832 return dma_map_sg(controller, sg, nents, 841 833 is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE); 842 834 } 835 + EXPORT_SYMBOL_GPL(usb_buffer_map_sg); 843 836 844 837 /* XXX DISABLED, no users currently. If you wish to re-enable this 845 838 * XXX please determine whether the sync is to transfer ownership of ··· 874 865 dma_sync_sg(controller, sg, n_hw_ents, 875 866 is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE); 876 867 } 868 + EXPORT_SYMBOL_GPL(usb_buffer_dmasync_sg); 877 869 #endif 878 870 879 871 /** ··· 901 891 dma_unmap_sg(controller, sg, n_hw_ents, 902 892 is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE); 903 893 } 894 + EXPORT_SYMBOL_GPL(usb_buffer_unmap_sg); 904 895 905 896 /* format to disable USB on kernel command line is: nousb */ 906 897 __module_param_call("", nousb, param_set_bool, param_get_bool, &nousb, 0444); ··· 913 902 { 914 903 return nousb; 915 904 } 905 + EXPORT_SYMBOL_GPL(usb_disabled); 916 906 917 907 /* 918 908 * Init ··· 930 918 if (retval) 931 919 goto out; 932 920 retval = bus_register(&usb_bus_type); 933 - if (retval) 921 + if (retval) 934 922 goto bus_register_failed; 935 923 retval = usb_host_init(); 936 924 if (retval) ··· 995 983 996 984 subsys_initcall(usb_init); 997 985 module_exit(usb_exit); 998 - 999 - /* 1000 - * USB may be built into the kernel or be built as modules. 1001 - * These symbols are exported for device (or host controller) 1002 - * driver modules to use. 1003 - */ 1004 - 1005 - EXPORT_SYMBOL(usb_disabled); 1006 - 1007 - EXPORT_SYMBOL_GPL(usb_get_intf); 1008 - EXPORT_SYMBOL_GPL(usb_put_intf); 1009 - 1010 - EXPORT_SYMBOL(usb_put_dev); 1011 - EXPORT_SYMBOL(usb_get_dev); 1012 - EXPORT_SYMBOL(usb_hub_tt_clear_buffer); 1013 - 1014 - EXPORT_SYMBOL(usb_lock_device_for_reset); 1015 - 1016 - EXPORT_SYMBOL(usb_find_interface); 1017 - EXPORT_SYMBOL(usb_ifnum_to_if); 1018 - EXPORT_SYMBOL(usb_altnum_to_altsetting); 1019 - 1020 - EXPORT_SYMBOL(__usb_get_extra_descriptor); 1021 - 1022 - EXPORT_SYMBOL(usb_get_current_frame_number); 1023 - 1024 - EXPORT_SYMBOL(usb_buffer_alloc); 1025 - EXPORT_SYMBOL(usb_buffer_free); 1026 - 1027 - #if 0 1028 - EXPORT_SYMBOL(usb_buffer_map); 1029 - EXPORT_SYMBOL(usb_buffer_dmasync); 1030 - EXPORT_SYMBOL(usb_buffer_unmap); 1031 - #endif 1032 - 1033 - EXPORT_SYMBOL(usb_buffer_map_sg); 1034 - #if 0 1035 - EXPORT_SYMBOL(usb_buffer_dmasync_sg); 1036 - #endif 1037 - EXPORT_SYMBOL(usb_buffer_unmap_sg); 1038 - 1039 986 MODULE_LICENSE("GPL");
+11 -10
drivers/usb/core/usb.h
··· 1 1 /* Functions local to drivers/usb/core/ */ 2 2 3 - extern int usb_create_sysfs_dev_files (struct usb_device *dev); 4 - extern void usb_remove_sysfs_dev_files (struct usb_device *dev); 5 - extern int usb_create_sysfs_intf_files (struct usb_interface *intf); 6 - extern void usb_remove_sysfs_intf_files (struct usb_interface *intf); 7 - extern int usb_create_ep_files(struct device *parent, struct usb_host_endpoint *endpoint, 3 + extern int usb_create_sysfs_dev_files(struct usb_device *dev); 4 + extern void usb_remove_sysfs_dev_files(struct usb_device *dev); 5 + extern int usb_create_sysfs_intf_files(struct usb_interface *intf); 6 + extern void usb_remove_sysfs_intf_files(struct usb_interface *intf); 7 + extern int usb_create_ep_files(struct device *parent, 8 + struct usb_host_endpoint *endpoint, 8 9 struct usb_device *udev); 9 10 extern void usb_remove_ep_files(struct usb_host_endpoint *endpoint); 10 11 11 12 extern void usb_enable_endpoint(struct usb_device *dev, 12 13 struct usb_host_endpoint *ep); 13 - extern void usb_disable_endpoint (struct usb_device *dev, unsigned int epaddr); 14 - extern void usb_disable_interface (struct usb_device *dev, 14 + extern void usb_disable_endpoint(struct usb_device *dev, unsigned int epaddr); 15 + extern void usb_disable_interface(struct usb_device *dev, 15 16 struct usb_interface *intf); 16 17 extern void usb_release_interface_cache(struct kref *ref); 17 - extern void usb_disable_device (struct usb_device *dev, int skip_ep0); 18 - extern int usb_deauthorize_device (struct usb_device *); 19 - extern int usb_authorize_device (struct usb_device *); 18 + extern void usb_disable_device(struct usb_device *dev, int skip_ep0); 19 + extern int usb_deauthorize_device(struct usb_device *); 20 + extern int usb_authorize_device(struct usb_device *); 20 21 extern void usb_detect_quirks(struct usb_device *udev); 21 22 22 23 extern int usb_get_device_descriptor(struct usb_device *dev,
+29 -4
drivers/usb/gadget/Kconfig
··· 12 12 # With help from a special transceiver and a "Mini-AB" jack, systems with 13 13 # both kinds of controller can also support "USB On-the-Go" (CONFIG_USB_OTG). 14 14 # 15 - menu "USB Gadget Support" 16 15 17 - config USB_GADGET 18 - tristate "Support for USB Gadgets" 16 + menuconfig USB_GADGET 17 + tristate "USB Gadget Support" 19 18 help 20 19 USB is a master/slave protocol, organized with one master 21 20 host (such as a PC) controlling up to 127 peripheral devices. ··· 40 41 41 42 For more information, see <http://www.linux-usb.org/gadget> and 42 43 the kernel DocBook documentation for this API. 44 + 45 + if USB_GADGET 43 46 44 47 config USB_GADGET_DEBUG 45 48 boolean "Debugging messages" ··· 220 219 depends on USB_GADGET_M66592 221 220 default USB_GADGET 222 221 select USB_GADGET_SELECTED 222 + 223 + config SUPERH_BUILT_IN_M66592 224 + boolean "Enable SuperH built-in USB like the M66592" 225 + depends on USB_GADGET_M66592 && CPU_SUBTYPE_SH7722 226 + help 227 + SH7722 has USB like the M66592. 228 + 229 + The transfer rate is very slow when use "Ethernet Gadget". 230 + However, this problem is improved if change a value of 231 + NET_IP_ALIGN to 4. 223 232 224 233 config USB_GADGET_GOKU 225 234 boolean "Toshiba TC86C001 'Goku-S'" ··· 549 538 Say "y" to link the driver statically, or "m" to build a 550 539 dynamically linked module called "g_midi". 551 540 541 + config USB_G_PRINTER 542 + tristate "Printer Gadget" 543 + help 544 + The Printer Gadget channels data between the USB host and a 545 + userspace program driving the print engine. The user space 546 + program reads and writes the device file /dev/g_printer to 547 + receive or send printer data. It can use ioctl calls to 548 + the device file to get or set printer status. 549 + 550 + Say "y" to link the driver statically, or "m" to build a 551 + dynamically linked module called "g_printer". 552 + 553 + For more information, see Documentation/usb/gadget_printer.txt 554 + which includes sample code for accessing the device file. 552 555 553 556 # put drivers that need isochronous transfer support (for audio 554 557 # or video class gadget drivers), or specific hardware, here. ··· 571 546 572 547 endchoice 573 548 574 - endmenu 549 + endif # USB_GADGET
+3
drivers/usb/gadget/Makefile
··· 28 28 gadgetfs-objs := inode.o 29 29 g_file_storage-objs := file_storage.o usbstring.o config.o \ 30 30 epautoconf.o 31 + g_printer-objs := printer.o usbstring.o config.o \ 32 + epautoconf.o 31 33 32 34 ifeq ($(CONFIG_USB_ETH_RNDIS),y) 33 35 g_ether-objs += rndis.o ··· 40 38 obj-$(CONFIG_USB_GADGETFS) += gadgetfs.o 41 39 obj-$(CONFIG_USB_FILE_STORAGE) += g_file_storage.o 42 40 obj-$(CONFIG_USB_G_SERIAL) += g_serial.o 41 + obj-$(CONFIG_USB_G_PRINTER) += g_printer.o 43 42 obj-$(CONFIG_USB_MIDI_GADGET) += g_midi.o 44 43
+2 -1
drivers/usb/gadget/amd5536udc.c
··· 1244 1244 /* stop OUT naking */ 1245 1245 if (!ep->in) { 1246 1246 if (!use_dma && udc_rxfifo_pending) { 1247 - DBG(dev, "udc_queue(): pending bytes in" 1247 + DBG(dev, "udc_queue(): pending bytes in " 1248 1248 "rxfifo after nyet\n"); 1249 1249 /* 1250 1250 * read pending bytes afer nyet: ··· 2038 2038 spin_unlock_irqrestore(&dev->lock, flags); 2039 2039 2040 2040 driver->unbind(&dev->gadget); 2041 + dev->gadget.dev.driver = NULL; 2041 2042 dev->driver = NULL; 2042 2043 2043 2044 /* set SD */
+65 -22
drivers/usb/gadget/at91_udc.c
··· 21 21 * Boston, MA 02111-1307, USA. 22 22 */ 23 23 24 - #undef DEBUG 25 - #undef VERBOSE 24 + #undef VERBOSE_DEBUG 26 25 #undef PACKET_TRACE 27 26 28 27 #include <linux/kernel.h> ··· 45 46 #include <asm/irq.h> 46 47 #include <asm/system.h> 47 48 #include <asm/mach-types.h> 49 + #include <asm/gpio.h> 48 50 49 - #include <asm/arch/gpio.h> 50 51 #include <asm/arch/board.h> 51 52 #include <asm/arch/cpu.h> 52 53 #include <asm/arch/at91sam9261_matrix.h> ··· 579 580 */ 580 581 581 582 static struct usb_request * 582 - at91_ep_alloc_request(struct usb_ep *_ep, unsigned int gfp_flags) 583 + at91_ep_alloc_request(struct usb_ep *_ep, gfp_t gfp_flags) 583 584 { 584 585 struct at91_request *req; 585 586 ··· 880 881 */ 881 882 static void pullup(struct at91_udc *udc, int is_on) 882 883 { 884 + int active = !udc->board.pullup_active_low; 885 + 883 886 if (!udc->enabled || !udc->vbus) 884 887 is_on = 0; 885 888 DBG("%sactive\n", is_on ? "" : "in"); ··· 891 890 at91_udp_write(udc, AT91_UDP_ICR, AT91_UDP_RXRSM); 892 891 at91_udp_write(udc, AT91_UDP_TXVC, 0); 893 892 if (cpu_is_at91rm9200()) 894 - at91_set_gpio_value(udc->board.pullup_pin, 1); 893 + gpio_set_value(udc->board.pullup_pin, active); 895 894 else if (cpu_is_at91sam9260() || cpu_is_at91sam9263()) { 896 895 u32 txvc = at91_udp_read(udc, AT91_UDP_TXVC); 897 896 ··· 909 908 at91_udp_write(udc, AT91_UDP_IDR, AT91_UDP_RXRSM); 910 909 at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS); 911 910 if (cpu_is_at91rm9200()) 912 - at91_set_gpio_value(udc->board.pullup_pin, 0); 911 + gpio_set_value(udc->board.pullup_pin, !active); 913 912 else if (cpu_is_at91sam9260() || cpu_is_at91sam9263()) { 914 913 u32 txvc = at91_udp_read(udc, AT91_UDP_TXVC); 915 914 ··· 1154 1153 | USB_REQ_GET_STATUS: 1155 1154 tmp = w_index & USB_ENDPOINT_NUMBER_MASK; 1156 1155 ep = &udc->ep[tmp]; 1157 - if (tmp > NUM_ENDPOINTS || (tmp && !ep->desc)) 1156 + if (tmp >= NUM_ENDPOINTS || (tmp && !ep->desc)) 1158 1157 goto stall; 1159 1158 1160 1159 if (tmp) { ··· 1177 1176 | USB_REQ_SET_FEATURE: 1178 1177 tmp = w_index & USB_ENDPOINT_NUMBER_MASK; 1179 1178 ep = &udc->ep[tmp]; 1180 - if (w_value != USB_ENDPOINT_HALT || tmp > NUM_ENDPOINTS) 1179 + if (w_value != USB_ENDPOINT_HALT || tmp >= NUM_ENDPOINTS) 1181 1180 goto stall; 1182 1181 if (!ep->desc || ep->is_iso) 1183 1182 goto stall; ··· 1196 1195 | USB_REQ_CLEAR_FEATURE: 1197 1196 tmp = w_index & USB_ENDPOINT_NUMBER_MASK; 1198 1197 ep = &udc->ep[tmp]; 1199 - if (w_value != USB_ENDPOINT_HALT || tmp > NUM_ENDPOINTS) 1198 + if (w_value != USB_ENDPOINT_HALT || tmp >= NUM_ENDPOINTS) 1200 1199 goto stall; 1201 1200 if (tmp == 0) 1202 1201 goto succeed; ··· 1552 1551 1553 1552 /* vbus needs at least brief debouncing */ 1554 1553 udelay(10); 1555 - value = at91_get_gpio_value(udc->board.vbus_pin); 1554 + value = gpio_get_value(udc->board.vbus_pin); 1556 1555 if (value != udc->vbus) 1557 1556 at91_vbus_session(&udc->gadget, value); 1558 1557 ··· 1617 1616 local_irq_enable(); 1618 1617 1619 1618 driver->unbind(&udc->gadget); 1619 + udc->gadget.dev.driver = NULL; 1620 + udc->gadget.dev.driver_data = NULL; 1620 1621 udc->driver = NULL; 1621 1622 1622 1623 DBG("unbound from %s\n", driver->driver.name); ··· 1648 1645 } 1649 1646 1650 1647 if (pdev->num_resources != 2) { 1651 - DBG("invalid num_resources"); 1648 + DBG("invalid num_resources\n"); 1652 1649 return -ENODEV; 1653 1650 } 1654 1651 if ((pdev->resource[0].flags != IORESOURCE_MEM) 1655 1652 || (pdev->resource[1].flags != IORESOURCE_IRQ)) { 1656 - DBG("invalid resource type"); 1653 + DBG("invalid resource type\n"); 1657 1654 return -ENODEV; 1658 1655 } 1659 1656 ··· 1675 1672 udc->pdev = pdev; 1676 1673 udc->enabled = 0; 1677 1674 1675 + /* rm9200 needs manual D+ pullup; off by default */ 1676 + if (cpu_is_at91rm9200()) { 1677 + if (udc->board.pullup_pin <= 0) { 1678 + DBG("no D+ pullup?\n"); 1679 + retval = -ENODEV; 1680 + goto fail0; 1681 + } 1682 + retval = gpio_request(udc->board.pullup_pin, "udc_pullup"); 1683 + if (retval) { 1684 + DBG("D+ pullup is busy\n"); 1685 + goto fail0; 1686 + } 1687 + gpio_direction_output(udc->board.pullup_pin, 1688 + udc->board.pullup_active_low); 1689 + } 1690 + 1678 1691 udc->udp_baseaddr = ioremap(res->start, res->end - res->start + 1); 1679 1692 if (!udc->udp_baseaddr) { 1680 - release_mem_region(res->start, res->end - res->start + 1); 1681 - return -ENOMEM; 1693 + retval = -ENOMEM; 1694 + goto fail0a; 1682 1695 } 1683 1696 1684 1697 udc_reinit(udc); ··· 1705 1686 if (IS_ERR(udc->iclk) || IS_ERR(udc->fclk)) { 1706 1687 DBG("clocks missing\n"); 1707 1688 retval = -ENODEV; 1708 - goto fail0; 1689 + /* NOTE: we "know" here that refcounts on these are NOPs */ 1690 + goto fail0b; 1709 1691 } 1710 1692 1711 1693 retval = device_register(&udc->gadget.dev); 1712 1694 if (retval < 0) 1713 - goto fail0; 1695 + goto fail0b; 1714 1696 1715 1697 /* don't do anything until we have both gadget driver and VBUS */ 1716 1698 clk_enable(udc->iclk); ··· 1723 1703 1724 1704 /* request UDC and maybe VBUS irqs */ 1725 1705 udc->udp_irq = platform_get_irq(pdev, 0); 1726 - if (request_irq(udc->udp_irq, at91_udc_irq, 1727 - IRQF_DISABLED, driver_name, udc)) { 1706 + retval = request_irq(udc->udp_irq, at91_udc_irq, 1707 + IRQF_DISABLED, driver_name, udc); 1708 + if (retval < 0) { 1728 1709 DBG("request irq %d failed\n", udc->udp_irq); 1729 - retval = -EBUSY; 1730 1710 goto fail1; 1731 1711 } 1732 1712 if (udc->board.vbus_pin > 0) { 1713 + retval = gpio_request(udc->board.vbus_pin, "udc_vbus"); 1714 + if (retval < 0) { 1715 + DBG("request vbus pin failed\n"); 1716 + goto fail2; 1717 + } 1718 + gpio_direction_input(udc->board.vbus_pin); 1719 + 1733 1720 /* 1734 1721 * Get the initial state of VBUS - we cannot expect 1735 1722 * a pending interrupt. 1736 1723 */ 1737 - udc->vbus = at91_get_gpio_value(udc->board.vbus_pin); 1724 + udc->vbus = gpio_get_value(udc->board.vbus_pin); 1738 1725 if (request_irq(udc->board.vbus_pin, at91_vbus_irq, 1739 1726 IRQF_DISABLED, driver_name, udc)) { 1740 1727 DBG("request vbus irq %d failed\n", 1741 1728 udc->board.vbus_pin); 1742 1729 free_irq(udc->udp_irq, udc); 1743 1730 retval = -EBUSY; 1744 - goto fail1; 1731 + goto fail3; 1745 1732 } 1746 1733 } else { 1747 1734 DBG("no VBUS detection, assuming always-on\n"); ··· 1761 1734 INFO("%s version %s\n", driver_name, DRIVER_VERSION); 1762 1735 return 0; 1763 1736 1737 + fail3: 1738 + if (udc->board.vbus_pin > 0) 1739 + gpio_free(udc->board.vbus_pin); 1740 + fail2: 1741 + free_irq(udc->udp_irq, udc); 1764 1742 fail1: 1765 1743 device_unregister(&udc->gadget.dev); 1744 + fail0b: 1745 + iounmap(udc->udp_baseaddr); 1746 + fail0a: 1747 + if (cpu_is_at91rm9200()) 1748 + gpio_free(udc->board.pullup_pin); 1766 1749 fail0: 1767 1750 release_mem_region(res->start, res->end - res->start + 1); 1768 1751 DBG("%s probe failed, %d\n", driver_name, retval); ··· 1793 1756 1794 1757 device_init_wakeup(&pdev->dev, 0); 1795 1758 remove_debug_file(udc); 1796 - if (udc->board.vbus_pin > 0) 1759 + if (udc->board.vbus_pin > 0) { 1797 1760 free_irq(udc->board.vbus_pin, udc); 1761 + gpio_free(udc->board.vbus_pin); 1762 + } 1798 1763 free_irq(udc->udp_irq, udc); 1799 1764 device_unregister(&udc->gadget.dev); 1800 1765 1801 1766 iounmap(udc->udp_baseaddr); 1767 + 1768 + if (cpu_is_at91rm9200()) 1769 + gpio_free(udc->board.pullup_pin); 1770 + 1802 1771 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1803 1772 release_mem_region(res->start, res->end - res->start + 1); 1804 1773
+6 -11
drivers/usb/gadget/at91_udc.h
··· 53 53 #define AT91_UDP_RXRSM (1 << 9) /* USB Resume Interrupt Status */ 54 54 #define AT91_UDP_EXTRSM (1 << 10) /* External Resume Interrupt Status [AT91RM9200 only] */ 55 55 #define AT91_UDP_SOFINT (1 << 11) /* Start of Frame Interrupt Status */ 56 - #define AT91_UDP_ENDBUSRES (1 << 12) /* End of Bus Reset Interrpt Status */ 56 + #define AT91_UDP_ENDBUSRES (1 << 12) /* End of Bus Reset Interrupt Status */ 57 57 #define AT91_UDP_WAKEUP (1 << 13) /* USB Wakeup Interrupt Status [AT91RM9200 only] */ 58 58 59 59 #define AT91_UDP_ICR 0x20 /* Interrupt Clear Register */ ··· 158 158 159 159 /*-------------------------------------------------------------------------*/ 160 160 161 - #ifdef DEBUG 162 - #define DBG(stuff...) printk(KERN_DEBUG "udc: " stuff) 163 - #else 164 - #define DBG(stuff...) do{}while(0) 165 - #endif 166 - 167 - #ifdef VERBOSE 161 + #ifdef VERBOSE_DEBUG 168 162 # define VDBG DBG 169 163 #else 170 164 # define VDBG(stuff...) do{}while(0) ··· 170 176 # define PACKET(stuff...) do{}while(0) 171 177 #endif 172 178 173 - #define ERR(stuff...) printk(KERN_ERR "udc: " stuff) 174 - #define WARN(stuff...) printk(KERN_WARNING "udc: " stuff) 175 - #define INFO(stuff...) printk(KERN_INFO "udc: " stuff) 179 + #define ERR(stuff...) pr_err("udc: " stuff) 180 + #define WARN(stuff...) pr_warning("udc: " stuff) 181 + #define INFO(stuff...) pr_info("udc: " stuff) 182 + #define DBG(stuff...) pr_debug("udc: " stuff) 176 183 177 184 #endif 178 185
+4 -7
drivers/usb/gadget/atmel_usba_udc.c
··· 1384 1384 return retval; 1385 1385 1386 1386 stall: 1387 - printk(KERN_ERR 1388 - "udc: %s: Invalid setup request: %02x.%02x v%04x i%04x l%d, " 1387 + pr_err("udc: %s: Invalid setup request: %02x.%02x v%04x i%04x l%d, " 1389 1388 "halting endpoint...\n", 1390 1389 ep->ep.name, crq->bRequestType, crq->bRequest, 1391 1390 le16_to_cpu(crq->wValue), le16_to_cpu(crq->wIndex), ··· 1455 1456 set_protocol_stall(udc, ep); 1456 1457 break; 1457 1458 default: 1458 - printk(KERN_ERR 1459 - "udc: %s: TXCOMP: Invalid endpoint state %d, " 1459 + pr_err("udc: %s: TXCOMP: Invalid endpoint state %d, " 1460 1460 "halting endpoint...\n", 1461 1461 ep->ep.name, ep->state); 1462 1462 set_protocol_stall(udc, ep); ··· 1484 1486 default: 1485 1487 usba_ep_writel(ep, CLR_STA, USBA_RX_BK_RDY); 1486 1488 usba_ep_writel(ep, CTL_DIS, USBA_RX_BK_RDY); 1487 - printk(KERN_ERR 1488 - "udc: %s: RXRDY: Invalid endpoint state %d, " 1489 + pr_err("udc: %s: RXRDY: Invalid endpoint state %d, " 1489 1490 "halting endpoint...\n", 1490 1491 ep->ep.name, ep->state); 1491 1492 set_protocol_stall(udc, ep); ··· 1529 1532 pkt_len = USBA_BFEXT(BYTE_COUNT, usba_ep_readl(ep, STA)); 1530 1533 DBG(DBG_HW, "Packet length: %u\n", pkt_len); 1531 1534 if (pkt_len != sizeof(crq)) { 1532 - printk(KERN_WARNING "udc: Invalid packet length %u " 1535 + pr_warning("udc: Invalid packet length %u " 1533 1536 "(expected %lu)\n", pkt_len, sizeof(crq)); 1534 1537 set_protocol_stall(udc, ep); 1535 1538 return;
+2 -5
drivers/usb/gadget/atmel_usba_udc.h
··· 216 216 #define FIFO_IOMEM_ID 0 217 217 #define CTRL_IOMEM_ID 1 218 218 219 - #ifdef DEBUG 220 219 #define DBG_ERR 0x0001 /* report all error returns */ 221 220 #define DBG_HW 0x0002 /* debug hardware initialization */ 222 221 #define DBG_GADGET 0x0004 /* calls to/from gadget driver */ ··· 229 230 #define DBG_NONE 0x0000 230 231 231 232 #define DEBUG_LEVEL (DBG_ERR) 233 + 232 234 #define DBG(level, fmt, ...) \ 233 235 do { \ 234 236 if ((level) & DEBUG_LEVEL) \ 235 - printk(KERN_DEBUG "udc: " fmt, ## __VA_ARGS__); \ 237 + pr_debug("udc: " fmt, ## __VA_ARGS__); \ 236 238 } while (0) 237 - #else 238 - #define DBG(level, fmt...) 239 - #endif 240 239 241 240 enum usba_ctrl_state { 242 241 WAIT_FOR_SETUP,
+11 -27
drivers/usb/gadget/dummy_hcd.c
··· 61 61 #define DRIVER_DESC "USB Host+Gadget Emulator" 62 62 #define DRIVER_VERSION "02 May 2005" 63 63 64 + #define POWER_BUDGET 500 /* in mA; use 8 for low-power port testing */ 65 + 64 66 static const char driver_name [] = "dummy_hcd"; 65 67 static const char driver_desc [] = "USB Host+Gadget Emulator"; 66 68 ··· 774 772 list_del_init (&dum->ep [0].ep.ep_list); 775 773 INIT_LIST_HEAD(&dum->fifo_req.queue); 776 774 775 + driver->driver.bus = NULL; 777 776 dum->driver = driver; 778 777 dum->gadget.dev.driver = &driver->driver; 779 778 dev_dbg (udc_dev(dum), "binding gadget driver '%s'\n", 780 779 driver->driver.name); 781 - if ((retval = driver->bind (&dum->gadget)) != 0) 782 - goto err_bind_gadget; 783 - 784 - driver->driver.bus = dum->gadget.dev.parent->bus; 785 - if ((retval = driver_register (&driver->driver)) != 0) 786 - goto err_register; 787 - if ((retval = device_bind_driver (&dum->gadget.dev)) != 0) 788 - goto err_bind_driver; 780 + retval = driver->bind(&dum->gadget); 781 + if (retval) { 782 + dum->driver = NULL; 783 + dum->gadget.dev.driver = NULL; 784 + return retval; 785 + } 789 786 790 787 /* khubd will enumerate this in a while */ 791 788 spin_lock_irq (&dum->lock); ··· 794 793 795 794 usb_hcd_poll_rh_status (dummy_to_hcd (dum)); 796 795 return 0; 797 - 798 - err_bind_driver: 799 - driver_unregister (&driver->driver); 800 - err_register: 801 - if (driver->unbind) 802 - driver->unbind (&dum->gadget); 803 - spin_lock_irq (&dum->lock); 804 - dum->pullup = 0; 805 - set_link_state (dum); 806 - spin_unlock_irq (&dum->lock); 807 - err_bind_gadget: 808 - dum->driver = NULL; 809 - dum->gadget.dev.driver = NULL; 810 - return retval; 811 796 } 812 797 EXPORT_SYMBOL (usb_gadget_register_driver); 813 798 ··· 817 830 spin_unlock_irqrestore (&dum->lock, flags); 818 831 819 832 driver->unbind (&dum->gadget); 833 + dum->gadget.dev.driver = NULL; 820 834 dum->driver = NULL; 821 - 822 - device_release_driver (&dum->gadget.dev); 823 - driver_unregister (&driver->driver); 824 835 825 836 spin_lock_irqsave (&dum->lock, flags); 826 837 dum->pullup = 0; ··· 1812 1827 1813 1828 INIT_LIST_HEAD (&dum->urbp_list); 1814 1829 1815 - /* only show a low-power port: just 8mA */ 1816 - hcd->power_budget = 8; 1830 + hcd->power_budget = POWER_BUDGET; 1817 1831 hcd->state = HC_STATE_RUNNING; 1818 1832 hcd->uses_new_polling = 1; 1819 1833
+3 -3
drivers/usb/gadget/ether.c
··· 1067 1067 1068 1068 /* on error, disable any endpoints */ 1069 1069 if (result < 0) { 1070 - if (!subset_active(dev)) 1070 + if (!subset_active(dev) && dev->status_ep) 1071 1071 (void) usb_ep_disable (dev->status_ep); 1072 1072 dev->status = NULL; 1073 1073 (void) usb_ep_disable (dev->in_ep); 1074 1074 (void) usb_ep_disable (dev->out_ep); 1075 1075 dev->in = NULL; 1076 1076 dev->out = NULL; 1077 - } else 1077 + } 1078 1078 1079 1079 /* activate non-CDC configs right away 1080 1080 * this isn't strictly according to the RNDIS spec 1081 1081 */ 1082 - if (!cdc_active (dev)) { 1082 + else if (!cdc_active (dev)) { 1083 1083 netif_carrier_on (dev->net); 1084 1084 if (netif_running (dev->net)) { 1085 1085 spin_unlock (&dev->lock);
+5 -9
drivers/usb/gadget/file_storage.c
··· 275 275 276 276 /*-------------------------------------------------------------------------*/ 277 277 278 - #ifdef DEBUG 279 278 #define LDBG(lun,fmt,args...) \ 280 279 dev_dbg(&(lun)->dev , fmt , ## args) 281 280 #define MDBG(fmt,args...) \ 282 - printk(KERN_DEBUG DRIVER_NAME ": " fmt , ## args) 283 - #else 284 - #define LDBG(lun,fmt,args...) \ 285 - do { } while (0) 286 - #define MDBG(fmt,args...) \ 287 - do { } while (0) 281 + pr_debug(DRIVER_NAME ": " fmt , ## args) 282 + 283 + #ifndef DEBUG 288 284 #undef VERBOSE_DEBUG 289 285 #undef DUMP_MSGS 290 - #endif /* DEBUG */ 286 + #endif /* !DEBUG */ 291 287 292 288 #ifdef VERBOSE_DEBUG 293 289 #define VLDBG LDBG ··· 300 304 dev_info(&(lun)->dev , fmt , ## args) 301 305 302 306 #define MINFO(fmt,args...) \ 303 - printk(KERN_INFO DRIVER_NAME ": " fmt , ## args) 307 + pr_info(DRIVER_NAME ": " fmt , ## args) 304 308 305 309 #define DBG(d, fmt, args...) \ 306 310 dev_dbg(&(d)->gadget->dev , fmt , ## args)
+2 -2
drivers/usb/gadget/fsl_usb2_udc.c
··· 776 776 VDBG("%s, bad params\n", __FUNCTION__); 777 777 return -EINVAL; 778 778 } 779 - if (!_ep || (!ep->desc && ep_index(ep))) { 779 + if (unlikely(!_ep || !ep->desc)) { 780 780 VDBG("%s, bad ep\n", __FUNCTION__); 781 781 return -EINVAL; 782 782 } ··· 1896 1896 1897 1897 spin_lock_irqsave(&udc->lock, flags); 1898 1898 1899 - /* ------basic driver infomation ---- */ 1899 + /* ------basic driver information ---- */ 1900 1900 t = scnprintf(next, size, 1901 1901 DRIVER_DESC "\n" 1902 1902 "%s version: %s\n"
+3 -3
drivers/usb/gadget/fsl_usb2_udc.h
··· 551 551 #define VDBG(stuff...) do{}while(0) 552 552 #endif 553 553 554 - #define ERR(stuff...) printk(KERN_ERR "udc: " stuff) 555 - #define WARN(stuff...) printk(KERN_WARNING "udc: " stuff) 556 - #define INFO(stuff...) printk(KERN_INFO "udc: " stuff) 554 + #define ERR(stuff...) pr_err("udc: " stuff) 555 + #define WARN(stuff...) pr_warning("udc: " stuff) 556 + #define INFO(stuff...) pr_info("udc: " stuff) 557 557 558 558 /*-------------------------------------------------------------------------*/ 559 559
+3 -3
drivers/usb/gadget/gmidi.c
··· 1158 1158 /* support optional vendor/distro customization */ 1159 1159 if (idVendor) { 1160 1160 if (!idProduct) { 1161 - printk(KERN_ERR "idVendor needs idProduct!\n"); 1161 + pr_err("idVendor needs idProduct!\n"); 1162 1162 return -ENODEV; 1163 1163 } 1164 1164 device_desc.idVendor = cpu_to_le16(idVendor); ··· 1190 1190 in_ep = usb_ep_autoconfig(gadget, &bulk_in_desc); 1191 1191 if (!in_ep) { 1192 1192 autoconf_fail: 1193 - printk(KERN_ERR "%s: can't autoconfigure on %s\n", 1193 + pr_err("%s: can't autoconfigure on %s\n", 1194 1194 shortname, gadget->name); 1195 1195 return -ENODEV; 1196 1196 } ··· 1212 1212 * it SHOULD NOT have problems with bulk-capable hardware. 1213 1213 * so warn about unrecognized controllers, don't panic. 1214 1214 */ 1215 - printk(KERN_WARNING "%s: controller '%s' not recognized\n", 1215 + pr_warning("%s: controller '%s' not recognized\n", 1216 1216 shortname, gadget->name); 1217 1217 device_desc.bcdDevice = __constant_cpu_to_le16(0x9999); 1218 1218 }
+1
drivers/usb/gadget/goku_udc.c
··· 1422 1422 spin_unlock_irqrestore(&dev->lock, flags); 1423 1423 1424 1424 driver->unbind(&dev->gadget); 1425 + dev->gadget.dev.driver = NULL; 1425 1426 1426 1427 DBG(dev, "unregistered driver '%s'\n", driver->driver.name); 1427 1428 return 0;
+1 -1
drivers/usb/gadget/inode.c
··· 1699 1699 if (!dev) 1700 1700 return -ESRCH; 1701 1701 if (0 != strcmp (CHIP, gadget->name)) { 1702 - printk (KERN_ERR "%s expected %s controller not %s\n", 1702 + pr_err("%s expected %s controller not %s\n", 1703 1703 shortname, CHIP, gadget->name); 1704 1704 return -ENODEV; 1705 1705 }
+1
drivers/usb/gadget/lh7a40x_udc.c
··· 474 474 spin_unlock_irqrestore(&dev->lock, flags); 475 475 476 476 driver->unbind(&dev->gadget); 477 + dev->gadget.dev.driver = NULL; 477 478 device_del(&dev->gadget.dev); 478 479 479 480 udc_disable(dev);
+79 -25
drivers/usb/gadget/m66592-udc.c
··· 36 36 MODULE_LICENSE("GPL"); 37 37 MODULE_AUTHOR("Yoshihiro Shimoda"); 38 38 39 - #define DRIVER_VERSION "29 May 2007" 39 + #define DRIVER_VERSION "18 Oct 2007" 40 40 41 41 /* module parameters */ 42 + #if defined(CONFIG_SUPERH_BUILT_IN_M66592) 43 + static unsigned short endian = M66592_LITTLE; 44 + module_param(endian, ushort, 0644); 45 + MODULE_PARM_DESC(endian, "data endian: big=0, little=0 (default=0)"); 46 + #else 42 47 static unsigned short clock = M66592_XTAL24; 43 48 module_param(clock, ushort, 0644); 44 49 MODULE_PARM_DESC(clock, "input clock: 48MHz=32768, 24MHz=16384, 12MHz=0 " ··· 61 56 module_param(irq_sense, ushort, 0644); 62 57 MODULE_PARM_DESC(irq_sense, "IRQ sense: low level=2, falling edge=0 " 63 58 "(default=2)"); 59 + #endif 64 60 65 61 static const char udc_name[] = "m66592_udc"; 66 62 static const char *m66592_ep_name[] = { ··· 147 141 offset = get_pipectr_addr(pipenum); 148 142 pid = m66592_read(m66592, offset) & M66592_PID; 149 143 } else 150 - printk(KERN_ERR "unexpect pipe num (%d)\n", pipenum); 144 + pr_err("unexpect pipe num (%d)\n", pipenum); 151 145 152 146 return pid; 153 147 } ··· 163 157 offset = get_pipectr_addr(pipenum); 164 158 m66592_mdfy(m66592, pid, M66592_PID, offset); 165 159 } else 166 - printk(KERN_ERR "unexpect pipe num (%d)\n", pipenum); 160 + pr_err("unexpect pipe num (%d)\n", pipenum); 167 161 } 168 162 169 163 static inline void pipe_start(struct m66592 *m66592, u16 pipenum) ··· 192 186 offset = get_pipectr_addr(pipenum); 193 187 ret = m66592_read(m66592, offset); 194 188 } else 195 - printk(KERN_ERR "unexpect pipe num (%d)\n", pipenum); 189 + pr_err("unexpect pipe num (%d)\n", pipenum); 196 190 197 191 return ret; 198 192 } ··· 209 203 offset = get_pipectr_addr(pipenum); 210 204 m66592_bset(m66592, M66592_SQCLR, offset); 211 205 } else 212 - printk(KERN_ERR "unexpect pipe num(%d)\n", pipenum); 206 + pr_err("unexpect pipe num(%d)\n", pipenum); 213 207 } 214 208 215 209 static inline int get_buffer_size(struct m66592 *m66592, u16 pipenum) ··· 291 285 break; 292 286 } 293 287 if (m66592->bi_bufnum > M66592_MAX_BUFNUM) { 294 - printk(KERN_ERR "m66592 pipe memory is insufficient(%d)\n", 288 + pr_err("m66592 pipe memory is insufficient(%d)\n", 295 289 m66592->bi_bufnum); 296 290 return -ENOMEM; 297 291 } ··· 332 326 if (info->type == M66592_BULK) 333 327 m66592->bulk--; 334 328 } else 335 - printk(KERN_ERR "ep_release: unexpect pipenum (%d)\n", 329 + pr_err("ep_release: unexpect pipenum (%d)\n", 336 330 info->pipe); 337 331 } 338 332 ··· 366 360 ep->fifosel = M66592_D0FIFOSEL; 367 361 ep->fifoctr = M66592_D0FIFOCTR; 368 362 ep->fifotrn = M66592_D0FIFOTRN; 363 + #if !defined(CONFIG_SUPERH_BUILT_IN_M66592) 369 364 } else if (m66592->num_dma == 1) { 370 365 m66592->num_dma++; 371 366 ep->use_dma = 1; ··· 374 367 ep->fifosel = M66592_D1FIFOSEL; 375 368 ep->fifoctr = M66592_D1FIFOCTR; 376 369 ep->fifotrn = M66592_D1FIFOTRN; 370 + #endif 377 371 } else { 378 372 ep->use_dma = 0; 379 373 ep->fifoaddr = M66592_CFIFO; ··· 430 422 case USB_ENDPOINT_XFER_BULK: 431 423 if (m66592->bulk >= M66592_MAX_NUM_BULK) { 432 424 if (m66592->isochronous >= M66592_MAX_NUM_ISOC) { 433 - printk(KERN_ERR "bulk pipe is insufficient\n"); 425 + pr_err("bulk pipe is insufficient\n"); 434 426 return -ENODEV; 435 427 } else { 436 428 info.pipe = M66592_BASE_PIPENUM_ISOC ··· 446 438 break; 447 439 case USB_ENDPOINT_XFER_INT: 448 440 if (m66592->interrupt >= M66592_MAX_NUM_INT) { 449 - printk(KERN_ERR "interrupt pipe is insufficient\n"); 441 + pr_err("interrupt pipe is insufficient\n"); 450 442 return -ENODEV; 451 443 } 452 444 info.pipe = M66592_BASE_PIPENUM_INT + m66592->interrupt; ··· 455 447 break; 456 448 case USB_ENDPOINT_XFER_ISOC: 457 449 if (m66592->isochronous >= M66592_MAX_NUM_ISOC) { 458 - printk(KERN_ERR "isochronous pipe is insufficient\n"); 450 + pr_err("isochronous pipe is insufficient\n"); 459 451 return -ENODEV; 460 452 } 461 453 info.pipe = M66592_BASE_PIPENUM_ISOC + m66592->isochronous; ··· 463 455 counter = &m66592->isochronous; 464 456 break; 465 457 default: 466 - printk(KERN_ERR "unexpect xfer type\n"); 458 + pr_err("unexpect xfer type\n"); 467 459 return -EINVAL; 468 460 } 469 461 ep->type = info.type; ··· 478 470 479 471 ret = pipe_buffer_setting(m66592, &info); 480 472 if (ret < 0) { 481 - printk(KERN_ERR "pipe_buffer_setting fail\n"); 473 + pr_err("pipe_buffer_setting fail\n"); 482 474 return ret; 483 475 } 484 476 ··· 614 606 control_end(ep->m66592, 0); 615 607 break; 616 608 default: 617 - printk(KERN_ERR "start_ep0: unexpect ctsq(%x)\n", ctsq); 609 + pr_err("start_ep0: unexpect ctsq(%x)\n", ctsq); 618 610 break; 619 611 } 620 612 } 621 613 614 + #if defined(CONFIG_SUPERH_BUILT_IN_M66592) 615 + static void init_controller(struct m66592 *m66592) 616 + { 617 + usbf_start_clock(); 618 + m66592_bset(m66592, M66592_HSE, M66592_SYSCFG); /* High spd */ 619 + m66592_bclr(m66592, M66592_USBE, M66592_SYSCFG); 620 + m66592_bclr(m66592, M66592_DPRPU, M66592_SYSCFG); 621 + m66592_bset(m66592, M66592_USBE, M66592_SYSCFG); 622 + 623 + /* This is a workaound for SH7722 2nd cut */ 624 + m66592_bset(m66592, 0x8000, M66592_DVSTCTR); 625 + m66592_bset(m66592, 0x1000, M66592_TESTMODE); 626 + m66592_bclr(m66592, 0x8000, M66592_DVSTCTR); 627 + 628 + m66592_bset(m66592, M66592_INTL, M66592_INTENB1); 629 + 630 + m66592_write(m66592, 0, M66592_CFBCFG); 631 + m66592_write(m66592, 0, M66592_D0FBCFG); 632 + m66592_bset(m66592, endian, M66592_CFBCFG); 633 + m66592_bset(m66592, endian, M66592_D0FBCFG); 634 + } 635 + #else /* #if defined(CONFIG_SUPERH_BUILT_IN_M66592) */ 622 636 static void init_controller(struct m66592 *m66592) 623 637 { 624 638 m66592_bset(m66592, (vif & M66592_LDRV) | (endian & M66592_BIGEND), ··· 666 636 m66592_write(m66592, M66592_BURST | M66592_CPU_ADR_RD_WR, 667 637 M66592_DMA0CFG); 668 638 } 639 + #endif /* #if defined(CONFIG_SUPERH_BUILT_IN_M66592) */ 669 640 670 641 static void disable_controller(struct m66592 *m66592) 671 642 { 643 + #if defined(CONFIG_SUPERH_BUILT_IN_M66592) 644 + usbf_stop_clock(); 645 + #else 672 646 m66592_bclr(m66592, M66592_SCKE, M66592_SYSCFG); 673 647 udelay(1); 674 648 m66592_bclr(m66592, M66592_PLLC, M66592_SYSCFG); ··· 680 646 m66592_bclr(m66592, M66592_RCKE, M66592_SYSCFG); 681 647 udelay(1); 682 648 m66592_bclr(m66592, M66592_XCKE, M66592_SYSCFG); 649 + #endif 683 650 } 684 651 685 652 static void m66592_start_xclock(struct m66592 *m66592) 686 653 { 654 + #if defined(CONFIG_SUPERH_BUILT_IN_M66592) 655 + usbf_start_clock(); 656 + #else 687 657 u16 tmp; 688 658 689 659 tmp = m66592_read(m66592, M66592_SYSCFG); 690 660 if (!(tmp & M66592_XCKE)) 691 661 m66592_bset(m66592, M66592_XCKE, M66592_SYSCFG); 662 + #endif 692 663 } 693 664 694 665 /*-------------------------------------------------------------------------*/ ··· 748 709 do { 749 710 tmp = m66592_read(m66592, ep->fifoctr); 750 711 if (i++ > 100000) { 751 - printk(KERN_ERR "pipe0 is busy. maybe cpu i/o bus" 712 + pr_err("pipe0 is busy. maybe cpu i/o bus " 752 713 "conflict. please power off this controller."); 753 714 return; 754 715 } ··· 798 759 if (unlikely((tmp & M66592_FRDY) == 0)) { 799 760 pipe_stop(m66592, pipenum); 800 761 pipe_irq_disable(m66592, pipenum); 801 - printk(KERN_ERR "write fifo not ready. pipnum=%d\n", pipenum); 762 + pr_err("write fifo not ready. pipnum=%d\n", pipenum); 802 763 return; 803 764 } 804 765 ··· 847 808 req->req.status = -EPIPE; 848 809 pipe_stop(m66592, pipenum); 849 810 pipe_irq_disable(m66592, pipenum); 850 - printk(KERN_ERR "read fifo not ready"); 811 + pr_err("read fifo not ready"); 851 812 return; 852 813 } 853 814 ··· 1102 1063 break; 1103 1064 default: 1104 1065 m66592->gadget.speed = USB_SPEED_UNKNOWN; 1105 - printk(KERN_ERR "USB speed unknown\n"); 1066 + pr_err("USB speed unknown\n"); 1106 1067 } 1107 1068 } 1108 1069 ··· 1161 1122 control_end(m66592, 0); 1162 1123 break; 1163 1124 default: 1164 - printk(KERN_ERR "ctrl_stage: unexpect ctsq(%x)\n", ctsq); 1125 + pr_err("ctrl_stage: unexpect ctsq(%x)\n", ctsq); 1165 1126 break; 1166 1127 } 1167 1128 } ··· 1180 1141 1181 1142 intsts0 = m66592_read(m66592, M66592_INTSTS0); 1182 1143 intenb0 = m66592_read(m66592, M66592_INTENB0); 1144 + 1145 + #if defined(CONFIG_SUPERH_BUILT_IN_M66592) 1146 + if (!intsts0 && !intenb0) { 1147 + /* 1148 + * When USB clock stops, it cannot read register. Even if a 1149 + * clock stops, the interrupt occurs. So this driver turn on 1150 + * a clock by this timing and do re-reading of register. 1151 + */ 1152 + m66592_start_xclock(m66592); 1153 + intsts0 = m66592_read(m66592, M66592_INTSTS0); 1154 + intenb0 = m66592_read(m66592, M66592_INTENB0); 1155 + } 1156 + #endif 1183 1157 1184 1158 savepipe = m66592_read(m66592, M66592_CFIFOSEL); 1185 1159 ··· 1461 1409 1462 1410 retval = device_add(&m66592->gadget.dev); 1463 1411 if (retval) { 1464 - printk(KERN_ERR "device_add error (%d)\n", retval); 1412 + pr_err("device_add error (%d)\n", retval); 1465 1413 goto error; 1466 1414 } 1467 1415 1468 1416 retval = driver->bind (&m66592->gadget); 1469 1417 if (retval) { 1470 - printk(KERN_ERR "bind to driver error (%d)\n", retval); 1418 + pr_err("bind to driver error (%d)\n", retval); 1471 1419 device_del(&m66592->gadget.dev); 1472 1420 goto error; 1473 1421 } ··· 1508 1456 m66592_bclr(m66592, M66592_VBSE | M66592_URST, M66592_INTENB0); 1509 1457 1510 1458 driver->unbind(&m66592->gadget); 1459 + m66592->gadget.dev.driver = NULL; 1511 1460 1512 1461 init_controller(m66592); 1513 1462 disable_controller(m66592); ··· 1538 1485 iounmap(m66592->reg); 1539 1486 free_irq(platform_get_irq(pdev, 0), m66592); 1540 1487 m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req); 1488 + usbf_stop_clock(); 1541 1489 kfree(m66592); 1542 1490 return 0; 1543 1491 } ··· 1562 1508 (char *)udc_name); 1563 1509 if (!res) { 1564 1510 ret = -ENODEV; 1565 - printk(KERN_ERR "platform_get_resource_byname error.\n"); 1511 + pr_err("platform_get_resource_byname error.\n"); 1566 1512 goto clean_up; 1567 1513 } 1568 1514 1569 1515 irq = platform_get_irq(pdev, 0); 1570 1516 if (irq < 0) { 1571 1517 ret = -ENODEV; 1572 - printk(KERN_ERR "platform_get_irq error.\n"); 1518 + pr_err("platform_get_irq error.\n"); 1573 1519 goto clean_up; 1574 1520 } 1575 1521 1576 1522 reg = ioremap(res->start, resource_len(res)); 1577 1523 if (reg == NULL) { 1578 1524 ret = -ENOMEM; 1579 - printk(KERN_ERR "ioremap error.\n"); 1525 + pr_err("ioremap error.\n"); 1580 1526 goto clean_up; 1581 1527 } 1582 1528 1583 1529 /* initialize ucd */ 1584 1530 m66592 = kzalloc(sizeof(struct m66592), GFP_KERNEL); 1585 1531 if (m66592 == NULL) { 1586 - printk(KERN_ERR "kzalloc error\n"); 1532 + pr_err("kzalloc error\n"); 1587 1533 goto clean_up; 1588 1534 } 1589 1535 ··· 1609 1555 ret = request_irq(irq, m66592_irq, IRQF_DISABLED | IRQF_SHARED, 1610 1556 udc_name, m66592); 1611 1557 if (ret < 0) { 1612 - printk(KERN_ERR "request_irq error (%d)\n", ret); 1558 + pr_err("request_irq error (%d)\n", ret); 1613 1559 goto clean_up; 1614 1560 } 1615 1561
+54
drivers/usb/gadget/m66592-udc.h
··· 72 72 #define M66592_P_TST_J 0x0001 /* PERI TEST J */ 73 73 #define M66592_P_TST_NORMAL 0x0000 /* PERI Normal Mode */ 74 74 75 + #if defined(CONFIG_SUPERH_BUILT_IN_M66592) 76 + #define M66592_CFBCFG 0x0A 77 + #define M66592_D0FBCFG 0x0C 78 + #define M66592_LITTLE 0x0100 /* b8: Little endian mode */ 79 + #else 75 80 #define M66592_PINCFG 0x0A 76 81 #define M66592_LDRV 0x8000 /* b15: Drive Current Adjust */ 77 82 #define M66592_BIGEND 0x0100 /* b8: Big endian mode */ ··· 96 91 #define M66592_PKTM 0x0020 /* b5: Packet mode */ 97 92 #define M66592_DENDE 0x0010 /* b4: Dend enable */ 98 93 #define M66592_OBUS 0x0004 /* b2: OUTbus mode */ 94 + #endif /* #if defined(CONFIG_SUPERH_BUILT_IN_M66592) */ 99 95 100 96 #define M66592_CFIFO 0x10 101 97 #define M66592_D0FIFO 0x14 ··· 109 103 #define M66592_REW 0x4000 /* b14: Buffer rewind */ 110 104 #define M66592_DCLRM 0x2000 /* b13: DMA buffer clear mode */ 111 105 #define M66592_DREQE 0x1000 /* b12: DREQ output enable */ 106 + #if defined(CONFIG_SUPERH_BUILT_IN_M66592) 107 + #define M66592_MBW 0x0800 /* b11: Maximum bit width for FIFO */ 108 + #else 112 109 #define M66592_MBW 0x0400 /* b10: Maximum bit width for FIFO */ 113 110 #define M66592_MBW_8 0x0000 /* 8bit */ 114 111 #define M66592_MBW_16 0x0400 /* 16bit */ 112 + #endif /* #if defined(CONFIG_SUPERH_BUILT_IN_M66592) */ 115 113 #define M66592_TRENB 0x0200 /* b9: Transaction counter enable */ 116 114 #define M66592_TRCLR 0x0100 /* b8: Transaction counter clear */ 117 115 #define M66592_DEZPM 0x0080 /* b7: Zero-length packet mode */ ··· 540 530 { 541 531 unsigned long fifoaddr = (unsigned long)m66592->reg + offset; 542 532 533 + #if defined(CONFIG_SUPERH_BUILT_IN_M66592) 534 + len = (len + 3) / 4; 535 + insl(fifoaddr, buf, len); 536 + #else 543 537 len = (len + 1) / 2; 544 538 insw(fifoaddr, buf, len); 539 + #endif 545 540 } 546 541 547 542 static inline void m66592_write(struct m66592 *m66592, u16 val, ··· 560 545 void *buf, unsigned long len) 561 546 { 562 547 unsigned long fifoaddr = (unsigned long)m66592->reg + offset; 548 + #if defined(CONFIG_SUPERH_BUILT_IN_M66592) 549 + unsigned long count; 550 + unsigned char *pb; 551 + int i; 552 + 553 + count = len / 4; 554 + outsl(fifoaddr, buf, count); 555 + 556 + if (len & 0x00000003) { 557 + pb = buf + count * 4; 558 + for (i = 0; i < (len & 0x00000003); i++) { 559 + if (m66592_read(m66592, M66592_CFBCFG)) /* little */ 560 + outb(pb[i], fifoaddr + (3 - i)); 561 + else 562 + outb(pb[i], fifoaddr + i); 563 + } 564 + } 565 + #else 563 566 unsigned long odd = len & 0x0001; 564 567 565 568 len = len / 2; ··· 586 553 unsigned char *p = buf + len*2; 587 554 outb(*p, fifoaddr); 588 555 } 556 + #endif /* #if defined(CONFIG_SUPERH_BUILT_IN_M66592) */ 589 557 } 590 558 591 559 static inline void m66592_mdfy(struct m66592 *m66592, u16 val, u16 pat, ··· 603 569 m66592_mdfy(m66592, 0, val, offset) 604 570 #define m66592_bset(m66592, val, offset) \ 605 571 m66592_mdfy(m66592, val, 0, offset) 572 + 573 + #if defined(CONFIG_SUPERH_BUILT_IN_M66592) 574 + #include <asm/io.h> 575 + #define MSTPCR2 0xA4150038 /* for SH7722 */ 576 + #define MSTPCR2_USB 0x00000800 577 + 578 + static inline void usbf_start_clock(void) 579 + { 580 + ctrl_outl(ctrl_inl(MSTPCR2) & ~MSTPCR2_USB, MSTPCR2); 581 + } 582 + 583 + static inline void usbf_stop_clock(void) 584 + { 585 + ctrl_outl(ctrl_inl(MSTPCR2) | MSTPCR2_USB, MSTPCR2); 586 + } 587 + 588 + #else 589 + #define usbf_start_clock(x) 590 + #define usbf_stop_clock(x) 591 + #endif /* if defined(CONFIG_SUPERH_BUILT_IN_M66592) */ 606 592 607 593 #endif /* ifndef __M66592_UDC_H__ */ 608 594
+1 -1
drivers/usb/gadget/net2280.c
··· 2435 2435 break; 2436 2436 default: 2437 2437 delegate: 2438 - VDEBUG (dev, "setup %02x.%02x v%04x i%04x l%04x" 2438 + VDEBUG (dev, "setup %02x.%02x v%04x i%04x l%04x " 2439 2439 "ep_cfg %08x\n", 2440 2440 u.r.bRequestType, u.r.bRequest, 2441 2441 w_value, w_index, w_length,
+50 -23
drivers/usb/gadget/omap_udc.c
··· 4 4 * Copyright (C) 2004 Texas Instruments, Inc. 5 5 * Copyright (C) 2004-2005 David Brownell 6 6 * 7 + * OMAP2 & DMA support by Kyungmin Park <kyungmin.park@samsung.com> 8 + * 7 9 * This program is free software; you can redistribute it and/or modify 8 10 * it under the terms of the GNU General Public License as published by 9 11 * the Free Software Foundation; either version 2 of the License, or ··· 62 60 /* bulk DMA seems to be behaving for both IN and OUT */ 63 61 #define USE_DMA 64 62 65 - /* FIXME: OMAP2 currently has some problem in DMA mode */ 66 - #ifdef CONFIG_ARCH_OMAP2 67 - #undef USE_DMA 68 - #endif 69 - 70 63 /* ISO too */ 71 64 #define USE_ISO 72 65 ··· 70 73 71 74 #define DMA_ADDR_INVALID (~(dma_addr_t)0) 72 75 76 + #define OMAP2_DMA_CH(ch) (((ch) - 1) << 1) 77 + #define OMAP24XX_DMA(name, ch) (OMAP24XX_DMA_##name + OMAP2_DMA_CH(ch)) 73 78 74 79 /* 75 80 * The OMAP UDC needs _very_ early endpoint setup: before enabling the ··· 570 571 const int sync_mode = cpu_is_omap15xx() 571 572 ? OMAP_DMA_SYNC_FRAME 572 573 : OMAP_DMA_SYNC_ELEMENT; 574 + int dma_trigger = 0; 575 + 576 + if (cpu_is_omap24xx()) 577 + dma_trigger = OMAP24XX_DMA(USB_W2FC_TX0, ep->dma_channel); 573 578 574 579 /* measure length in either bytes or packets */ 575 580 if ((cpu_is_omap16xx() && length <= UDC_TXN_TSC) 581 + || (cpu_is_omap24xx() && length < ep->maxpacket) 576 582 || (cpu_is_omap15xx() && length < ep->maxpacket)) { 577 583 txdma_ctrl = UDC_TXN_EOT | length; 578 584 omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S8, 579 - length, 1, sync_mode, 0, 0); 585 + length, 1, sync_mode, dma_trigger, 0); 580 586 } else { 581 587 length = min(length / ep->maxpacket, 582 588 (unsigned) UDC_TXN_TSC + 1); 583 589 txdma_ctrl = length; 584 590 omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S16, 585 591 ep->ep.maxpacket >> 1, length, sync_mode, 586 - 0, 0); 592 + dma_trigger, 0); 587 593 length *= ep->maxpacket; 588 594 } 589 595 omap_set_dma_src_params(ep->lch, OMAP_DMA_PORT_EMIFF, ··· 626 622 627 623 static void next_out_dma(struct omap_ep *ep, struct omap_req *req) 628 624 { 629 - unsigned packets; 625 + unsigned packets = req->req.length - req->req.actual; 626 + int dma_trigger = 0; 627 + 628 + if (cpu_is_omap24xx()) 629 + dma_trigger = OMAP24XX_DMA(USB_W2FC_RX0, ep->dma_channel); 630 630 631 631 /* NOTE: we filtered out "short reads" before, so we know 632 632 * the buffer has only whole numbers of packets. 633 + * except MODE SELECT(6) sent the 24 bytes data in OMAP24XX DMA mode 633 634 */ 634 - 635 - /* set up this DMA transfer, enable the fifo, start */ 636 - packets = (req->req.length - req->req.actual) / ep->ep.maxpacket; 637 - packets = min(packets, (unsigned)UDC_RXN_TC + 1); 638 - req->dma_bytes = packets * ep->ep.maxpacket; 639 - omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S16, 640 - ep->ep.maxpacket >> 1, packets, 641 - OMAP_DMA_SYNC_ELEMENT, 642 - 0, 0); 635 + if (cpu_is_omap24xx() && packets < ep->maxpacket) { 636 + omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S8, 637 + packets, 1, OMAP_DMA_SYNC_ELEMENT, 638 + dma_trigger, 0); 639 + req->dma_bytes = packets; 640 + } else { 641 + /* set up this DMA transfer, enable the fifo, start */ 642 + packets /= ep->ep.maxpacket; 643 + packets = min(packets, (unsigned)UDC_RXN_TC + 1); 644 + req->dma_bytes = packets * ep->ep.maxpacket; 645 + omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S16, 646 + ep->ep.maxpacket >> 1, packets, 647 + OMAP_DMA_SYNC_ELEMENT, 648 + dma_trigger, 0); 649 + } 643 650 omap_set_dma_dest_params(ep->lch, OMAP_DMA_PORT_EMIFF, 644 651 OMAP_DMA_AMODE_POST_INC, req->req.dma + req->req.actual, 645 652 0, 0); ··· 758 743 { 759 744 u16 reg; 760 745 int status, restart, is_in; 746 + int dma_channel; 761 747 762 748 is_in = ep->bEndpointAddress & USB_DIR_IN; 763 749 if (is_in) ··· 785 769 ep->dma_channel = channel; 786 770 787 771 if (is_in) { 788 - status = omap_request_dma(OMAP_DMA_USB_W2FC_TX0 - 1 + channel, 772 + if (cpu_is_omap24xx()) 773 + dma_channel = OMAP24XX_DMA(USB_W2FC_TX0, channel); 774 + else 775 + dma_channel = OMAP_DMA_USB_W2FC_TX0 - 1 + channel; 776 + status = omap_request_dma(dma_channel, 789 777 ep->ep.name, dma_error, ep, &ep->lch); 790 778 if (status == 0) { 791 779 UDC_TXDMA_CFG_REG = reg; 792 - /* EMIFF */ 780 + /* EMIFF or SDRC */ 793 781 omap_set_dma_src_burst_mode(ep->lch, 794 782 OMAP_DMA_DATA_BURST_4); 795 783 omap_set_dma_src_data_pack(ep->lch, 1); ··· 805 785 0, 0); 806 786 } 807 787 } else { 808 - status = omap_request_dma(OMAP_DMA_USB_W2FC_RX0 - 1 + channel, 788 + if (cpu_is_omap24xx()) 789 + dma_channel = OMAP24XX_DMA(USB_W2FC_RX0, channel); 790 + else 791 + dma_channel = OMAP_DMA_USB_W2FC_RX0 - 1 + channel; 792 + 793 + status = omap_request_dma(dma_channel, 809 794 ep->ep.name, dma_error, ep, &ep->lch); 810 795 if (status == 0) { 811 796 UDC_RXDMA_CFG_REG = reg; ··· 820 795 OMAP_DMA_AMODE_CONSTANT, 821 796 (unsigned long) io_v2p((u32)&UDC_DATA_DMA_REG), 822 797 0, 0); 823 - /* EMIFF */ 798 + /* EMIFF or SDRC */ 824 799 omap_set_dma_dest_burst_mode(ep->lch, 825 800 OMAP_DMA_DATA_BURST_4); 826 801 omap_set_dma_dest_data_pack(ep->lch, 1); ··· 833 808 omap_disable_dma_irq(ep->lch, OMAP_DMA_BLOCK_IRQ); 834 809 835 810 /* channel type P: hw synch (fifo) */ 836 - if (!cpu_is_omap15xx()) 811 + if (cpu_class_is_omap1() && !cpu_is_omap15xx()) 837 812 OMAP1_DMA_LCH_CTRL_REG(ep->lch) = 2; 838 813 } 839 814 ··· 951 926 952 927 /* this isn't bogus, but OMAP DMA isn't the only hardware to 953 928 * have a hard time with partial packet reads... reject it. 929 + * Except OMAP2 can handle the small packets. 954 930 */ 955 931 if (use_dma 956 932 && ep->has_dma 957 933 && ep->bEndpointAddress != 0 958 934 && (ep->bEndpointAddress & USB_DIR_IN) == 0 935 + && !cpu_class_is_omap2() 959 936 && (req->req.length % ep->ep.maxpacket) != 0) { 960 937 DBG("%s, no partial packet OUT reads\n", __FUNCTION__); 961 938 return -EMSGSIZE; ··· 1028 1001 1029 1002 /* STATUS for zero length DATA stages is 1030 1003 * always an IN ... even for IN transfers, 1031 - * a wierd case which seem to stall OMAP. 1004 + * a weird case which seem to stall OMAP. 1032 1005 */ 1033 1006 UDC_EP_NUM_REG = (UDC_EP_SEL|UDC_EP_DIR); 1034 1007 UDC_CTRL_REG = UDC_CLR_EP;
+4 -9
drivers/usb/gadget/omap_udc.h
··· 182 182 183 183 /*-------------------------------------------------------------------------*/ 184 184 185 - #ifdef DEBUG 186 - #define DBG(stuff...) printk(KERN_DEBUG "udc: " stuff) 187 - #else 188 - #define DBG(stuff...) do{}while(0) 189 - #endif 190 - 191 185 #ifdef VERBOSE 192 186 # define VDBG DBG 193 187 #else 194 188 # define VDBG(stuff...) do{}while(0) 195 189 #endif 196 190 197 - #define ERR(stuff...) printk(KERN_ERR "udc: " stuff) 198 - #define WARN(stuff...) printk(KERN_WARNING "udc: " stuff) 199 - #define INFO(stuff...) printk(KERN_INFO "udc: " stuff) 191 + #define ERR(stuff...) pr_err("udc: " stuff) 192 + #define WARN(stuff...) pr_warning("udc: " stuff) 193 + #define INFO(stuff...) pr_info("udc: " stuff) 194 + #define DBG(stuff...) pr_debug("udc: " stuff) 200 195 201 196 /*-------------------------------------------------------------------------*/ 202 197
+1592
drivers/usb/gadget/printer.c
··· 1 + /* 2 + * printer.c -- Printer gadget driver 3 + * 4 + * Copyright (C) 2003-2005 David Brownell 5 + * Copyright (C) 2006 Craig W. Nadler 6 + * 7 + * This program is free software; you can redistribute it and/or modify 8 + * it under the terms of the GNU General Public License as published by 9 + * the Free Software Foundation; either version 2 of the License, or 10 + * (at your option) any later version. 11 + * 12 + * This program is distributed in the hope that it will be useful, 13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 + * GNU General Public License for more details. 16 + * 17 + * You should have received a copy of the GNU General Public License 18 + * along with this program; if not, write to the Free Software 19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 + */ 21 + 22 + #include <linux/module.h> 23 + #include <linux/kernel.h> 24 + #include <linux/delay.h> 25 + #include <linux/ioport.h> 26 + #include <linux/sched.h> 27 + #include <linux/slab.h> 28 + #include <linux/smp_lock.h> 29 + #include <linux/errno.h> 30 + #include <linux/init.h> 31 + #include <linux/timer.h> 32 + #include <linux/list.h> 33 + #include <linux/interrupt.h> 34 + #include <linux/utsname.h> 35 + #include <linux/device.h> 36 + #include <linux/moduleparam.h> 37 + #include <linux/fs.h> 38 + #include <linux/poll.h> 39 + #include <linux/types.h> 40 + #include <linux/ctype.h> 41 + #include <linux/cdev.h> 42 + 43 + #include <asm/byteorder.h> 44 + #include <linux/io.h> 45 + #include <linux/irq.h> 46 + #include <asm/system.h> 47 + #include <linux/uaccess.h> 48 + #include <asm/unaligned.h> 49 + 50 + #include <linux/usb/ch9.h> 51 + #include <linux/usb/gadget.h> 52 + #include <linux/usb/g_printer.h> 53 + 54 + #include "gadget_chips.h" 55 + 56 + #define DRIVER_DESC "Printer Gadget" 57 + #define DRIVER_VERSION "2007 OCT 06" 58 + 59 + static const char shortname [] = "printer"; 60 + static const char driver_desc [] = DRIVER_DESC; 61 + 62 + static dev_t g_printer_devno; 63 + 64 + static struct class *usb_gadget_class; 65 + 66 + /*-------------------------------------------------------------------------*/ 67 + 68 + struct printer_dev { 69 + spinlock_t lock; /* lock this structure */ 70 + /* lock buffer lists during read/write calls */ 71 + spinlock_t lock_printer_io; 72 + struct usb_gadget *gadget; 73 + struct usb_request *req; /* for control responses */ 74 + u8 config; 75 + s8 interface; 76 + struct usb_ep *in_ep, *out_ep; 77 + const struct usb_endpoint_descriptor 78 + *in, *out; 79 + struct list_head rx_reqs; /* List of free RX structs */ 80 + struct list_head rx_reqs_active; /* List of Active RX xfers */ 81 + struct list_head rx_buffers; /* List of completed xfers */ 82 + /* wait until there is data to be read. */ 83 + wait_queue_head_t rx_wait; 84 + struct list_head tx_reqs; /* List of free TX structs */ 85 + struct list_head tx_reqs_active; /* List of Active TX xfers */ 86 + /* Wait until there are write buffers available to use. */ 87 + wait_queue_head_t tx_wait; 88 + /* Wait until all write buffers have been sent. */ 89 + wait_queue_head_t tx_flush_wait; 90 + struct usb_request *current_rx_req; 91 + size_t current_rx_bytes; 92 + u8 *current_rx_buf; 93 + u8 printer_status; 94 + u8 reset_printer; 95 + struct class_device *printer_class_dev; 96 + struct cdev printer_cdev; 97 + struct device *pdev; 98 + u8 printer_cdev_open; 99 + wait_queue_head_t wait; 100 + }; 101 + 102 + static struct printer_dev usb_printer_gadget; 103 + 104 + /*-------------------------------------------------------------------------*/ 105 + 106 + /* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!! 107 + * Instead: allocate your own, using normal USB-IF procedures. 108 + */ 109 + 110 + /* Thanks to NetChip Technologies for donating this product ID. 111 + */ 112 + #define PRINTER_VENDOR_NUM 0x0525 /* NetChip */ 113 + #define PRINTER_PRODUCT_NUM 0xa4a8 /* Linux-USB Printer Gadget */ 114 + 115 + /* Some systems will want different product identifers published in the 116 + * device descriptor, either numbers or strings or both. These string 117 + * parameters are in UTF-8 (superset of ASCII's 7 bit characters). 118 + */ 119 + 120 + static ushort __initdata idVendor; 121 + module_param(idVendor, ushort, S_IRUGO); 122 + MODULE_PARM_DESC(idVendor, "USB Vendor ID"); 123 + 124 + static ushort __initdata idProduct; 125 + module_param(idProduct, ushort, S_IRUGO); 126 + MODULE_PARM_DESC(idProduct, "USB Product ID"); 127 + 128 + static ushort __initdata bcdDevice; 129 + module_param(bcdDevice, ushort, S_IRUGO); 130 + MODULE_PARM_DESC(bcdDevice, "USB Device version (BCD)"); 131 + 132 + static char *__initdata iManufacturer; 133 + module_param(iManufacturer, charp, S_IRUGO); 134 + MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string"); 135 + 136 + static char *__initdata iProduct; 137 + module_param(iProduct, charp, S_IRUGO); 138 + MODULE_PARM_DESC(iProduct, "USB Product string"); 139 + 140 + static char *__initdata iSerialNum; 141 + module_param(iSerialNum, charp, S_IRUGO); 142 + MODULE_PARM_DESC(iSerialNum, "1"); 143 + 144 + static char *__initdata iPNPstring; 145 + module_param(iPNPstring, charp, S_IRUGO); 146 + MODULE_PARM_DESC(iPNPstring, "MFG:linux;MDL:g_printer;CLS:PRINTER;SN:1;"); 147 + 148 + /* Number of requests to allocate per endpoint, not used for ep0. */ 149 + static unsigned qlen = 10; 150 + module_param(qlen, uint, S_IRUGO|S_IWUSR); 151 + 152 + #define QLEN qlen 153 + 154 + #ifdef CONFIG_USB_GADGET_DUALSPEED 155 + #define DEVSPEED USB_SPEED_HIGH 156 + #else /* full speed (low speed doesn't do bulk) */ 157 + #define DEVSPEED USB_SPEED_FULL 158 + #endif 159 + 160 + /*-------------------------------------------------------------------------*/ 161 + 162 + #define xprintk(d, level, fmt, args...) \ 163 + printk(level "%s: " fmt, DRIVER_DESC, ## args) 164 + 165 + #ifdef DEBUG 166 + #define DBG(dev, fmt, args...) \ 167 + xprintk(dev, KERN_DEBUG, fmt, ## args) 168 + #else 169 + #define DBG(dev, fmt, args...) \ 170 + do { } while (0) 171 + #endif /* DEBUG */ 172 + 173 + #ifdef VERBOSE 174 + #define VDBG(dev, fmt, args...) \ 175 + xprintk(dev, KERN_DEBUG, fmt, ## args) 176 + #else 177 + #define VDBG(dev, fmt, args...) \ 178 + do { } while (0) 179 + #endif /* VERBOSE */ 180 + 181 + #define ERROR(dev, fmt, args...) \ 182 + xprintk(dev, KERN_ERR, fmt, ## args) 183 + #define WARN(dev, fmt, args...) \ 184 + xprintk(dev, KERN_WARNING, fmt, ## args) 185 + #define INFO(dev, fmt, args...) \ 186 + xprintk(dev, KERN_INFO, fmt, ## args) 187 + 188 + /*-------------------------------------------------------------------------*/ 189 + 190 + /* USB DRIVER HOOKUP (to the hardware driver, below us), mostly 191 + * ep0 implementation: descriptors, config management, setup(). 192 + * also optional class-specific notification interrupt transfer. 193 + */ 194 + 195 + /* 196 + * DESCRIPTORS ... most are static, but strings and (full) configuration 197 + * descriptors are built on demand. 198 + */ 199 + 200 + #define STRING_MANUFACTURER 1 201 + #define STRING_PRODUCT 2 202 + #define STRING_SERIALNUM 3 203 + 204 + /* holds our biggest descriptor */ 205 + #define USB_DESC_BUFSIZE 256 206 + #define USB_BUFSIZE 8192 207 + 208 + /* This device advertises one configuration. */ 209 + #define DEV_CONFIG_VALUE 1 210 + #define PRINTER_INTERFACE 0 211 + 212 + static struct usb_device_descriptor device_desc = { 213 + .bLength = sizeof device_desc, 214 + .bDescriptorType = USB_DT_DEVICE, 215 + .bcdUSB = __constant_cpu_to_le16(0x0200), 216 + .bDeviceClass = USB_CLASS_PER_INTERFACE, 217 + .bDeviceSubClass = 0, 218 + .bDeviceProtocol = 0, 219 + .idVendor = __constant_cpu_to_le16(PRINTER_VENDOR_NUM), 220 + .idProduct = __constant_cpu_to_le16(PRINTER_PRODUCT_NUM), 221 + .iManufacturer = STRING_MANUFACTURER, 222 + .iProduct = STRING_PRODUCT, 223 + .iSerialNumber = STRING_SERIALNUM, 224 + .bNumConfigurations = 1 225 + }; 226 + 227 + static struct usb_otg_descriptor otg_desc = { 228 + .bLength = sizeof otg_desc, 229 + .bDescriptorType = USB_DT_OTG, 230 + .bmAttributes = USB_OTG_SRP 231 + }; 232 + 233 + static struct usb_config_descriptor config_desc = { 234 + .bLength = sizeof config_desc, 235 + .bDescriptorType = USB_DT_CONFIG, 236 + 237 + /* compute wTotalLength on the fly */ 238 + .bNumInterfaces = 1, 239 + .bConfigurationValue = DEV_CONFIG_VALUE, 240 + .iConfiguration = 0, 241 + .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER, 242 + .bMaxPower = 1 /* Self-Powered */ 243 + }; 244 + 245 + static struct usb_interface_descriptor intf_desc = { 246 + .bLength = sizeof intf_desc, 247 + .bDescriptorType = USB_DT_INTERFACE, 248 + .bInterfaceNumber = PRINTER_INTERFACE, 249 + .bNumEndpoints = 2, 250 + .bInterfaceClass = USB_CLASS_PRINTER, 251 + .bInterfaceSubClass = 1, /* Printer Sub-Class */ 252 + .bInterfaceProtocol = 2, /* Bi-Directional */ 253 + .iInterface = 0 254 + }; 255 + 256 + static struct usb_endpoint_descriptor fs_ep_in_desc = { 257 + .bLength = USB_DT_ENDPOINT_SIZE, 258 + .bDescriptorType = USB_DT_ENDPOINT, 259 + .bEndpointAddress = USB_DIR_IN, 260 + .bmAttributes = USB_ENDPOINT_XFER_BULK 261 + }; 262 + 263 + static struct usb_endpoint_descriptor fs_ep_out_desc = { 264 + .bLength = USB_DT_ENDPOINT_SIZE, 265 + .bDescriptorType = USB_DT_ENDPOINT, 266 + .bEndpointAddress = USB_DIR_OUT, 267 + .bmAttributes = USB_ENDPOINT_XFER_BULK 268 + }; 269 + 270 + static const struct usb_descriptor_header *fs_printer_function [11] = { 271 + (struct usb_descriptor_header *) &otg_desc, 272 + (struct usb_descriptor_header *) &intf_desc, 273 + (struct usb_descriptor_header *) &fs_ep_in_desc, 274 + (struct usb_descriptor_header *) &fs_ep_out_desc, 275 + NULL 276 + }; 277 + 278 + #ifdef CONFIG_USB_GADGET_DUALSPEED 279 + 280 + /* 281 + * usb 2.0 devices need to expose both high speed and full speed 282 + * descriptors, unless they only run at full speed. 283 + */ 284 + 285 + static struct usb_endpoint_descriptor hs_ep_in_desc = { 286 + .bLength = USB_DT_ENDPOINT_SIZE, 287 + .bDescriptorType = USB_DT_ENDPOINT, 288 + .bmAttributes = USB_ENDPOINT_XFER_BULK, 289 + .wMaxPacketSize = __constant_cpu_to_le16(512) 290 + }; 291 + 292 + static struct usb_endpoint_descriptor hs_ep_out_desc = { 293 + .bLength = USB_DT_ENDPOINT_SIZE, 294 + .bDescriptorType = USB_DT_ENDPOINT, 295 + .bmAttributes = USB_ENDPOINT_XFER_BULK, 296 + .wMaxPacketSize = __constant_cpu_to_le16(512) 297 + }; 298 + 299 + static struct usb_qualifier_descriptor dev_qualifier = { 300 + .bLength = sizeof dev_qualifier, 301 + .bDescriptorType = USB_DT_DEVICE_QUALIFIER, 302 + .bcdUSB = __constant_cpu_to_le16(0x0200), 303 + .bDeviceClass = USB_CLASS_PRINTER, 304 + .bNumConfigurations = 1 305 + }; 306 + 307 + static const struct usb_descriptor_header *hs_printer_function [11] = { 308 + (struct usb_descriptor_header *) &otg_desc, 309 + (struct usb_descriptor_header *) &intf_desc, 310 + (struct usb_descriptor_header *) &hs_ep_in_desc, 311 + (struct usb_descriptor_header *) &hs_ep_out_desc, 312 + NULL 313 + }; 314 + 315 + /* maxpacket and other transfer characteristics vary by speed. */ 316 + #define ep_desc(g, hs, fs) (((g)->speed == USB_SPEED_HIGH)?(hs):(fs)) 317 + 318 + #else 319 + 320 + /* if there's no high speed support, maxpacket doesn't change. */ 321 + #define ep_desc(g, hs, fs) (((void)(g)), (fs)) 322 + 323 + #endif /* !CONFIG_USB_GADGET_DUALSPEED */ 324 + 325 + /*-------------------------------------------------------------------------*/ 326 + 327 + /* descriptors that are built on-demand */ 328 + 329 + static char manufacturer [50]; 330 + static char product_desc [40] = DRIVER_DESC; 331 + static char serial_num [40] = "1"; 332 + static char pnp_string [1024] = 333 + "XXMFG:linux;MDL:g_printer;CLS:PRINTER;SN:1;"; 334 + 335 + /* static strings, in UTF-8 */ 336 + static struct usb_string strings [] = { 337 + { STRING_MANUFACTURER, manufacturer, }, 338 + { STRING_PRODUCT, product_desc, }, 339 + { STRING_SERIALNUM, serial_num, }, 340 + { } /* end of list */ 341 + }; 342 + 343 + static struct usb_gadget_strings stringtab = { 344 + .language = 0x0409, /* en-us */ 345 + .strings = strings, 346 + }; 347 + 348 + /*-------------------------------------------------------------------------*/ 349 + 350 + static struct usb_request * 351 + printer_req_alloc(struct usb_ep *ep, unsigned len, gfp_t gfp_flags) 352 + { 353 + struct usb_request *req; 354 + 355 + req = usb_ep_alloc_request(ep, gfp_flags); 356 + 357 + if (req != NULL) { 358 + req->length = len; 359 + req->buf = kmalloc(len, gfp_flags); 360 + if (req->buf == NULL) { 361 + usb_ep_free_request(ep, req); 362 + return NULL; 363 + } 364 + } 365 + 366 + return req; 367 + } 368 + 369 + static void 370 + printer_req_free(struct usb_ep *ep, struct usb_request *req) 371 + { 372 + if (ep != NULL && req != NULL) { 373 + kfree(req->buf); 374 + usb_ep_free_request(ep, req); 375 + } 376 + } 377 + 378 + /*-------------------------------------------------------------------------*/ 379 + 380 + static void rx_complete(struct usb_ep *ep, struct usb_request *req) 381 + { 382 + struct printer_dev *dev = ep->driver_data; 383 + int status = req->status; 384 + unsigned long flags; 385 + 386 + spin_lock_irqsave(&dev->lock, flags); 387 + 388 + list_del_init(&req->list); /* Remode from Active List */ 389 + 390 + switch (status) { 391 + 392 + /* normal completion */ 393 + case 0: 394 + list_add_tail(&req->list, &dev->rx_buffers); 395 + wake_up_interruptible(&dev->rx_wait); 396 + DBG(dev, "G_Printer : rx length %d\n", req->actual); 397 + break; 398 + 399 + /* software-driven interface shutdown */ 400 + case -ECONNRESET: /* unlink */ 401 + case -ESHUTDOWN: /* disconnect etc */ 402 + VDBG(dev, "rx shutdown, code %d\n", status); 403 + list_add(&req->list, &dev->rx_reqs); 404 + break; 405 + 406 + /* for hardware automagic (such as pxa) */ 407 + case -ECONNABORTED: /* endpoint reset */ 408 + DBG(dev, "rx %s reset\n", ep->name); 409 + list_add(&req->list, &dev->rx_reqs); 410 + break; 411 + 412 + /* data overrun */ 413 + case -EOVERFLOW: 414 + /* FALLTHROUGH */ 415 + 416 + default: 417 + DBG(dev, "rx status %d\n", status); 418 + list_add(&req->list, &dev->rx_reqs); 419 + break; 420 + } 421 + spin_unlock_irqrestore(&dev->lock, flags); 422 + } 423 + 424 + static void tx_complete(struct usb_ep *ep, struct usb_request *req) 425 + { 426 + struct printer_dev *dev = ep->driver_data; 427 + 428 + switch (req->status) { 429 + default: 430 + VDBG(dev, "tx err %d\n", req->status); 431 + /* FALLTHROUGH */ 432 + case -ECONNRESET: /* unlink */ 433 + case -ESHUTDOWN: /* disconnect etc */ 434 + break; 435 + case 0: 436 + break; 437 + } 438 + 439 + spin_lock(&dev->lock); 440 + /* Take the request struct off the active list and put it on the 441 + * free list. 442 + */ 443 + list_del_init(&req->list); 444 + list_add(&req->list, &dev->tx_reqs); 445 + wake_up_interruptible(&dev->tx_wait); 446 + if (likely(list_empty(&dev->tx_reqs_active))) 447 + wake_up_interruptible(&dev->tx_flush_wait); 448 + 449 + spin_unlock(&dev->lock); 450 + } 451 + 452 + /*-------------------------------------------------------------------------*/ 453 + 454 + static int 455 + printer_open(struct inode *inode, struct file *fd) 456 + { 457 + struct printer_dev *dev; 458 + unsigned long flags; 459 + int ret = -EBUSY; 460 + 461 + dev = container_of(inode->i_cdev, struct printer_dev, printer_cdev); 462 + 463 + spin_lock_irqsave(&dev->lock, flags); 464 + 465 + if (!dev->printer_cdev_open) { 466 + dev->printer_cdev_open = 1; 467 + fd->private_data = dev; 468 + ret = 0; 469 + /* Change the printer status to show that it's on-line. */ 470 + dev->printer_status |= PRINTER_SELECTED; 471 + } 472 + 473 + spin_unlock_irqrestore(&dev->lock, flags); 474 + 475 + DBG(dev, "printer_open returned %x\n", ret); 476 + 477 + return ret; 478 + } 479 + 480 + static int 481 + printer_close(struct inode *inode, struct file *fd) 482 + { 483 + struct printer_dev *dev = fd->private_data; 484 + unsigned long flags; 485 + 486 + spin_lock_irqsave(&dev->lock, flags); 487 + dev->printer_cdev_open = 0; 488 + fd->private_data = NULL; 489 + /* Change printer status to show that the printer is off-line. */ 490 + dev->printer_status &= ~PRINTER_SELECTED; 491 + spin_unlock_irqrestore(&dev->lock, flags); 492 + 493 + DBG(dev, "printer_close\n"); 494 + 495 + return 0; 496 + } 497 + 498 + static ssize_t 499 + printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr) 500 + { 501 + struct printer_dev *dev = fd->private_data; 502 + unsigned long flags; 503 + size_t size; 504 + size_t bytes_copied; 505 + struct usb_request *req; 506 + /* This is a pointer to the current USB rx request. */ 507 + struct usb_request *current_rx_req; 508 + /* This is the number of bytes in the current rx buffer. */ 509 + size_t current_rx_bytes; 510 + /* This is a pointer to the current rx buffer. */ 511 + u8 *current_rx_buf; 512 + 513 + if (len == 0) 514 + return -EINVAL; 515 + 516 + DBG(dev, "printer_read trying to read %d bytes\n", (int)len); 517 + 518 + spin_lock(&dev->lock_printer_io); 519 + spin_lock_irqsave(&dev->lock, flags); 520 + 521 + /* We will use this flag later to check if a printer reset happened 522 + * after we turn interrupts back on. 523 + */ 524 + dev->reset_printer = 0; 525 + 526 + while (likely(!list_empty(&dev->rx_reqs))) { 527 + int error; 528 + 529 + req = container_of(dev->rx_reqs.next, 530 + struct usb_request, list); 531 + list_del_init(&req->list); 532 + 533 + /* The USB Host sends us whatever amount of data it wants to 534 + * so we always set the length field to the full USB_BUFSIZE. 535 + * If the amount of data is more than the read() caller asked 536 + * for it will be stored in the request buffer until it is 537 + * asked for by read(). 538 + */ 539 + req->length = USB_BUFSIZE; 540 + req->complete = rx_complete; 541 + 542 + error = usb_ep_queue(dev->out_ep, req, GFP_ATOMIC); 543 + if (error) { 544 + DBG(dev, "rx submit --> %d\n", error); 545 + list_add(&req->list, &dev->rx_reqs); 546 + break; 547 + } else { 548 + list_add(&req->list, &dev->rx_reqs_active); 549 + } 550 + } 551 + 552 + bytes_copied = 0; 553 + current_rx_req = dev->current_rx_req; 554 + current_rx_bytes = dev->current_rx_bytes; 555 + current_rx_buf = dev->current_rx_buf; 556 + dev->current_rx_req = NULL; 557 + dev->current_rx_bytes = 0; 558 + dev->current_rx_buf = NULL; 559 + 560 + /* Check if there is any data in the read buffers. Please note that 561 + * current_rx_bytes is the number of bytes in the current rx buffer. 562 + * If it is zero then check if there are any other rx_buffers that 563 + * are on the completed list. We are only out of data if all rx 564 + * buffers are empty. 565 + */ 566 + if ((current_rx_bytes == 0) && 567 + (likely(list_empty(&dev->rx_buffers)))) { 568 + /* Turn interrupts back on before sleeping. */ 569 + spin_unlock_irqrestore(&dev->lock, flags); 570 + 571 + /* 572 + * If no data is available check if this is a NON-Blocking 573 + * call or not. 574 + */ 575 + if (fd->f_flags & (O_NONBLOCK|O_NDELAY)) { 576 + spin_unlock(&dev->lock_printer_io); 577 + return -EAGAIN; 578 + } 579 + 580 + /* Sleep until data is available */ 581 + wait_event_interruptible(dev->rx_wait, 582 + (likely(!list_empty(&dev->rx_buffers)))); 583 + spin_lock_irqsave(&dev->lock, flags); 584 + } 585 + 586 + /* We have data to return then copy it to the caller's buffer.*/ 587 + while ((current_rx_bytes || likely(!list_empty(&dev->rx_buffers))) 588 + && len) { 589 + if (current_rx_bytes == 0) { 590 + req = container_of(dev->rx_buffers.next, 591 + struct usb_request, list); 592 + list_del_init(&req->list); 593 + 594 + if (req->actual && req->buf) { 595 + current_rx_req = req; 596 + current_rx_bytes = req->actual; 597 + current_rx_buf = req->buf; 598 + } else { 599 + list_add(&req->list, &dev->rx_reqs); 600 + continue; 601 + } 602 + } 603 + 604 + /* Don't leave irqs off while doing memory copies */ 605 + spin_unlock_irqrestore(&dev->lock, flags); 606 + 607 + if (len > current_rx_bytes) 608 + size = current_rx_bytes; 609 + else 610 + size = len; 611 + 612 + size -= copy_to_user(buf, current_rx_buf, size); 613 + bytes_copied += size; 614 + len -= size; 615 + buf += size; 616 + 617 + spin_lock_irqsave(&dev->lock, flags); 618 + 619 + /* We've disconnected or reset free the req and buffer */ 620 + if (dev->reset_printer) { 621 + printer_req_free(dev->out_ep, current_rx_req); 622 + spin_unlock_irqrestore(&dev->lock, flags); 623 + spin_unlock(&dev->lock_printer_io); 624 + return -EAGAIN; 625 + } 626 + 627 + /* If we not returning all the data left in this RX request 628 + * buffer then adjust the amount of data left in the buffer. 629 + * Othewise if we are done with this RX request buffer then 630 + * requeue it to get any incoming data from the USB host. 631 + */ 632 + if (size < current_rx_bytes) { 633 + current_rx_bytes -= size; 634 + current_rx_buf += size; 635 + } else { 636 + list_add(&current_rx_req->list, &dev->rx_reqs); 637 + current_rx_bytes = 0; 638 + current_rx_buf = NULL; 639 + current_rx_req = NULL; 640 + } 641 + } 642 + 643 + dev->current_rx_req = current_rx_req; 644 + dev->current_rx_bytes = current_rx_bytes; 645 + dev->current_rx_buf = current_rx_buf; 646 + 647 + spin_unlock_irqrestore(&dev->lock, flags); 648 + spin_unlock(&dev->lock_printer_io); 649 + 650 + DBG(dev, "printer_read returned %d bytes\n", (int)bytes_copied); 651 + 652 + if (bytes_copied) 653 + return bytes_copied; 654 + else 655 + return -EAGAIN; 656 + } 657 + 658 + static ssize_t 659 + printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr) 660 + { 661 + struct printer_dev *dev = fd->private_data; 662 + unsigned long flags; 663 + size_t size; /* Amount of data in a TX request. */ 664 + size_t bytes_copied = 0; 665 + struct usb_request *req; 666 + 667 + DBG(dev, "printer_write trying to send %d bytes\n", (int)len); 668 + 669 + if (len == 0) 670 + return -EINVAL; 671 + 672 + spin_lock(&dev->lock_printer_io); 673 + spin_lock_irqsave(&dev->lock, flags); 674 + 675 + /* Check if a printer reset happens while we have interrupts on */ 676 + dev->reset_printer = 0; 677 + 678 + /* Check if there is any available write buffers */ 679 + if (likely(list_empty(&dev->tx_reqs))) { 680 + /* Turn interrupts back on before sleeping. */ 681 + spin_unlock_irqrestore(&dev->lock, flags); 682 + 683 + /* 684 + * If write buffers are available check if this is 685 + * a NON-Blocking call or not. 686 + */ 687 + if (fd->f_flags & (O_NONBLOCK|O_NDELAY)) { 688 + spin_unlock(&dev->lock_printer_io); 689 + return -EAGAIN; 690 + } 691 + 692 + /* Sleep until a write buffer is available */ 693 + wait_event_interruptible(dev->tx_wait, 694 + (likely(!list_empty(&dev->tx_reqs)))); 695 + spin_lock_irqsave(&dev->lock, flags); 696 + } 697 + 698 + while (likely(!list_empty(&dev->tx_reqs)) && len) { 699 + 700 + if (len > USB_BUFSIZE) 701 + size = USB_BUFSIZE; 702 + else 703 + size = len; 704 + 705 + req = container_of(dev->tx_reqs.next, struct usb_request, 706 + list); 707 + list_del_init(&req->list); 708 + 709 + req->complete = tx_complete; 710 + req->length = size; 711 + 712 + /* Check if we need to send a zero length packet. */ 713 + if (len > size) 714 + /* They will be more TX requests so no yet. */ 715 + req->zero = 0; 716 + else 717 + /* If the data amount is not a multple of the 718 + * maxpacket size then send a zero length packet. 719 + */ 720 + req->zero = ((len % dev->in_ep->maxpacket) == 0); 721 + 722 + /* Don't leave irqs off while doing memory copies */ 723 + spin_unlock_irqrestore(&dev->lock, flags); 724 + 725 + if (copy_from_user(req->buf, buf, size)) { 726 + list_add(&req->list, &dev->tx_reqs); 727 + spin_unlock(&dev->lock_printer_io); 728 + return bytes_copied; 729 + } 730 + 731 + bytes_copied += size; 732 + len -= size; 733 + buf += size; 734 + 735 + spin_lock_irqsave(&dev->lock, flags); 736 + 737 + /* We've disconnected or reset so free the req and buffer */ 738 + if (dev->reset_printer) { 739 + printer_req_free(dev->in_ep, req); 740 + spin_unlock_irqrestore(&dev->lock, flags); 741 + spin_unlock(&dev->lock_printer_io); 742 + return -EAGAIN; 743 + } 744 + 745 + if (usb_ep_queue(dev->in_ep, req, GFP_ATOMIC)) { 746 + list_add(&req->list, &dev->tx_reqs); 747 + spin_unlock_irqrestore(&dev->lock, flags); 748 + spin_unlock(&dev->lock_printer_io); 749 + return -EAGAIN; 750 + } 751 + 752 + list_add(&req->list, &dev->tx_reqs_active); 753 + 754 + } 755 + 756 + spin_unlock_irqrestore(&dev->lock, flags); 757 + spin_unlock(&dev->lock_printer_io); 758 + 759 + DBG(dev, "printer_write sent %d bytes\n", (int)bytes_copied); 760 + 761 + if (bytes_copied) { 762 + return bytes_copied; 763 + } else { 764 + return -EAGAIN; 765 + } 766 + } 767 + 768 + static int 769 + printer_fsync(struct file *fd, struct dentry *dentry, int datasync) 770 + { 771 + struct printer_dev *dev = fd->private_data; 772 + unsigned long flags; 773 + int tx_list_empty; 774 + 775 + spin_lock_irqsave(&dev->lock, flags); 776 + tx_list_empty = (likely(list_empty(&dev->tx_reqs))); 777 + spin_unlock_irqrestore(&dev->lock, flags); 778 + 779 + if (!tx_list_empty) { 780 + /* Sleep until all data has been sent */ 781 + wait_event_interruptible(dev->tx_flush_wait, 782 + (likely(list_empty(&dev->tx_reqs_active)))); 783 + } 784 + 785 + return 0; 786 + } 787 + 788 + static unsigned int 789 + printer_poll(struct file *fd, poll_table *wait) 790 + { 791 + struct printer_dev *dev = fd->private_data; 792 + unsigned long flags; 793 + int status = 0; 794 + 795 + poll_wait(fd, &dev->rx_wait, wait); 796 + poll_wait(fd, &dev->tx_wait, wait); 797 + 798 + spin_lock_irqsave(&dev->lock, flags); 799 + if (likely(!list_empty(&dev->tx_reqs))) 800 + status |= POLLOUT | POLLWRNORM; 801 + 802 + if (likely(!list_empty(&dev->rx_buffers))) 803 + status |= POLLIN | POLLRDNORM; 804 + 805 + spin_unlock_irqrestore(&dev->lock, flags); 806 + 807 + return status; 808 + } 809 + 810 + static int 811 + printer_ioctl(struct inode *inode, struct file *fd, unsigned int code, 812 + unsigned long arg) 813 + { 814 + struct printer_dev *dev = fd->private_data; 815 + unsigned long flags; 816 + int status = 0; 817 + 818 + DBG(dev, "printer_ioctl: cmd=0x%4.4x, arg=%lu\n", code, arg); 819 + 820 + /* handle ioctls */ 821 + 822 + spin_lock_irqsave(&dev->lock, flags); 823 + 824 + switch (code) { 825 + case GADGET_GET_PRINTER_STATUS: 826 + status = (int)dev->printer_status; 827 + break; 828 + case GADGET_SET_PRINTER_STATUS: 829 + dev->printer_status = (u8)arg; 830 + break; 831 + default: 832 + /* could not handle ioctl */ 833 + DBG(dev, "printer_ioctl: ERROR cmd=0x%4.4xis not supported\n", 834 + code); 835 + status = -ENOTTY; 836 + } 837 + 838 + spin_unlock_irqrestore(&dev->lock, flags); 839 + 840 + return status; 841 + } 842 + 843 + /* used after endpoint configuration */ 844 + static struct file_operations printer_io_operations = { 845 + .owner = THIS_MODULE, 846 + .open = printer_open, 847 + .read = printer_read, 848 + .write = printer_write, 849 + .fsync = printer_fsync, 850 + .poll = printer_poll, 851 + .ioctl = printer_ioctl, 852 + .release = printer_close 853 + }; 854 + 855 + /*-------------------------------------------------------------------------*/ 856 + 857 + static int 858 + set_printer_interface(struct printer_dev *dev) 859 + { 860 + int result = 0; 861 + 862 + dev->in = ep_desc(dev->gadget, &hs_ep_in_desc, &fs_ep_in_desc); 863 + dev->in_ep->driver_data = dev; 864 + 865 + dev->out = ep_desc(dev->gadget, &hs_ep_out_desc, &fs_ep_out_desc); 866 + dev->out_ep->driver_data = dev; 867 + 868 + result = usb_ep_enable(dev->in_ep, dev->in); 869 + if (result != 0) { 870 + DBG(dev, "enable %s --> %d\n", dev->in_ep->name, result); 871 + goto done; 872 + } 873 + 874 + result = usb_ep_enable(dev->out_ep, dev->out); 875 + if (result != 0) { 876 + DBG(dev, "enable %s --> %d\n", dev->in_ep->name, result); 877 + goto done; 878 + } 879 + 880 + done: 881 + /* on error, disable any endpoints */ 882 + if (result != 0) { 883 + (void) usb_ep_disable(dev->in_ep); 884 + (void) usb_ep_disable(dev->out_ep); 885 + dev->in = NULL; 886 + dev->out = NULL; 887 + } 888 + 889 + /* caller is responsible for cleanup on error */ 890 + return result; 891 + } 892 + 893 + static void printer_reset_interface(struct printer_dev *dev) 894 + { 895 + if (dev->interface < 0) 896 + return; 897 + 898 + DBG(dev, "%s\n", __FUNCTION__); 899 + 900 + if (dev->in) 901 + usb_ep_disable(dev->in_ep); 902 + 903 + if (dev->out) 904 + usb_ep_disable(dev->out_ep); 905 + 906 + dev->interface = -1; 907 + } 908 + 909 + /* change our operational config. must agree with the code 910 + * that returns config descriptors, and altsetting code. 911 + */ 912 + static int 913 + printer_set_config(struct printer_dev *dev, unsigned number) 914 + { 915 + int result = 0; 916 + struct usb_gadget *gadget = dev->gadget; 917 + 918 + if (gadget_is_sa1100(gadget) && dev->config) { 919 + /* tx fifo is full, but we can't clear it...*/ 920 + INFO(dev, "can't change configurations\n"); 921 + return -ESPIPE; 922 + } 923 + 924 + switch (number) { 925 + case DEV_CONFIG_VALUE: 926 + result = 0; 927 + break; 928 + default: 929 + result = -EINVAL; 930 + /* FALL THROUGH */ 931 + case 0: 932 + break; 933 + } 934 + 935 + if (result) { 936 + usb_gadget_vbus_draw(dev->gadget, 937 + dev->gadget->is_otg ? 8 : 100); 938 + } else { 939 + char *speed; 940 + unsigned power; 941 + 942 + power = 2 * config_desc.bMaxPower; 943 + usb_gadget_vbus_draw(dev->gadget, power); 944 + 945 + switch (gadget->speed) { 946 + case USB_SPEED_FULL: speed = "full"; break; 947 + #ifdef CONFIG_USB_GADGET_DUALSPEED 948 + case USB_SPEED_HIGH: speed = "high"; break; 949 + #endif 950 + default: speed = "?"; break; 951 + } 952 + 953 + dev->config = number; 954 + INFO(dev, "%s speed config #%d: %d mA, %s\n", 955 + speed, number, power, driver_desc); 956 + } 957 + return result; 958 + } 959 + 960 + static int 961 + config_buf(enum usb_device_speed speed, u8 *buf, u8 type, unsigned index, 962 + int is_otg) 963 + { 964 + int len; 965 + const struct usb_descriptor_header **function; 966 + #ifdef CONFIG_USB_GADGET_DUALSPEED 967 + int hs = (speed == USB_SPEED_HIGH); 968 + 969 + if (type == USB_DT_OTHER_SPEED_CONFIG) 970 + hs = !hs; 971 + 972 + if (hs) { 973 + function = hs_printer_function; 974 + } else { 975 + function = fs_printer_function; 976 + } 977 + #else 978 + function = fs_printer_function; 979 + #endif 980 + 981 + if (index >= device_desc.bNumConfigurations) 982 + return -EINVAL; 983 + 984 + /* for now, don't advertise srp-only devices */ 985 + if (!is_otg) 986 + function++; 987 + 988 + len = usb_gadget_config_buf(&config_desc, buf, USB_DESC_BUFSIZE, 989 + function); 990 + if (len < 0) 991 + return len; 992 + ((struct usb_config_descriptor *) buf)->bDescriptorType = type; 993 + return len; 994 + } 995 + 996 + /* Change our operational Interface. */ 997 + static int 998 + set_interface(struct printer_dev *dev, unsigned number) 999 + { 1000 + int result = 0; 1001 + 1002 + if (gadget_is_sa1100(dev->gadget) && dev->interface < 0) { 1003 + /* tx fifo is full, but we can't clear it...*/ 1004 + INFO(dev, "can't change interfaces\n"); 1005 + return -ESPIPE; 1006 + } 1007 + 1008 + /* Free the current interface */ 1009 + switch (dev->interface) { 1010 + case PRINTER_INTERFACE: 1011 + printer_reset_interface(dev); 1012 + break; 1013 + } 1014 + 1015 + switch (number) { 1016 + case PRINTER_INTERFACE: 1017 + result = set_printer_interface(dev); 1018 + if (result) { 1019 + printer_reset_interface(dev); 1020 + } else { 1021 + dev->interface = PRINTER_INTERFACE; 1022 + } 1023 + break; 1024 + default: 1025 + result = -EINVAL; 1026 + /* FALL THROUGH */ 1027 + } 1028 + 1029 + if (!result) 1030 + INFO(dev, "Using interface %x\n", number); 1031 + 1032 + return result; 1033 + } 1034 + 1035 + static void printer_setup_complete(struct usb_ep *ep, struct usb_request *req) 1036 + { 1037 + if (req->status || req->actual != req->length) 1038 + DBG((struct printer_dev *) ep->driver_data, 1039 + "setup complete --> %d, %d/%d\n", 1040 + req->status, req->actual, req->length); 1041 + } 1042 + 1043 + static void printer_soft_reset(struct printer_dev *dev) 1044 + { 1045 + struct usb_request *req; 1046 + 1047 + INFO(dev, "Received Printer Reset Request\n"); 1048 + 1049 + if (usb_ep_disable(dev->in_ep)) 1050 + DBG(dev, "Failed to disable USB in_ep\n"); 1051 + if (usb_ep_disable(dev->out_ep)) 1052 + DBG(dev, "Failed to disable USB out_ep\n"); 1053 + 1054 + if (dev->current_rx_req != NULL) { 1055 + list_add(&dev->current_rx_req->list, &dev->rx_reqs); 1056 + dev->current_rx_req = NULL; 1057 + } 1058 + dev->current_rx_bytes = 0; 1059 + dev->current_rx_buf = NULL; 1060 + dev->reset_printer = 1; 1061 + 1062 + while (likely(!(list_empty(&dev->rx_buffers)))) { 1063 + req = container_of(dev->rx_buffers.next, struct usb_request, 1064 + list); 1065 + list_del_init(&req->list); 1066 + list_add(&req->list, &dev->rx_reqs); 1067 + } 1068 + 1069 + while (likely(!(list_empty(&dev->rx_reqs_active)))) { 1070 + req = container_of(dev->rx_buffers.next, struct usb_request, 1071 + list); 1072 + list_del_init(&req->list); 1073 + list_add(&req->list, &dev->rx_reqs); 1074 + } 1075 + 1076 + while (likely(!(list_empty(&dev->tx_reqs_active)))) { 1077 + req = container_of(dev->tx_reqs_active.next, 1078 + struct usb_request, list); 1079 + list_del_init(&req->list); 1080 + list_add(&req->list, &dev->tx_reqs); 1081 + } 1082 + 1083 + if (usb_ep_enable(dev->in_ep, dev->in)) 1084 + DBG(dev, "Failed to enable USB in_ep\n"); 1085 + if (usb_ep_enable(dev->out_ep, dev->out)) 1086 + DBG(dev, "Failed to enable USB out_ep\n"); 1087 + 1088 + wake_up_interruptible(&dev->tx_wait); 1089 + wake_up_interruptible(&dev->tx_flush_wait); 1090 + } 1091 + 1092 + /*-------------------------------------------------------------------------*/ 1093 + 1094 + /* 1095 + * The setup() callback implements all the ep0 functionality that's not 1096 + * handled lower down. 1097 + */ 1098 + static int 1099 + printer_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) 1100 + { 1101 + struct printer_dev *dev = get_gadget_data(gadget); 1102 + struct usb_request *req = dev->req; 1103 + int value = -EOPNOTSUPP; 1104 + u16 wIndex = le16_to_cpu(ctrl->wIndex); 1105 + u16 wValue = le16_to_cpu(ctrl->wValue); 1106 + u16 wLength = le16_to_cpu(ctrl->wLength); 1107 + 1108 + DBG(dev, "ctrl req%02x.%02x v%04x i%04x l%d\n", 1109 + ctrl->bRequestType, ctrl->bRequest, wValue, wIndex, wLength); 1110 + 1111 + req->complete = printer_setup_complete; 1112 + 1113 + switch (ctrl->bRequestType&USB_TYPE_MASK) { 1114 + 1115 + case USB_TYPE_STANDARD: 1116 + switch (ctrl->bRequest) { 1117 + 1118 + case USB_REQ_GET_DESCRIPTOR: 1119 + if (ctrl->bRequestType != USB_DIR_IN) 1120 + break; 1121 + switch (wValue >> 8) { 1122 + 1123 + case USB_DT_DEVICE: 1124 + value = min(wLength, (u16) sizeof device_desc); 1125 + memcpy(req->buf, &device_desc, value); 1126 + break; 1127 + #ifdef CONFIG_USB_GADGET_DUALSPEED 1128 + case USB_DT_DEVICE_QUALIFIER: 1129 + if (!gadget->is_dualspeed) 1130 + break; 1131 + value = min(wLength, 1132 + (u16) sizeof dev_qualifier); 1133 + memcpy(req->buf, &dev_qualifier, value); 1134 + break; 1135 + 1136 + case USB_DT_OTHER_SPEED_CONFIG: 1137 + if (!gadget->is_dualspeed) 1138 + break; 1139 + /* FALLTHROUGH */ 1140 + #endif /* CONFIG_USB_GADGET_DUALSPEED */ 1141 + case USB_DT_CONFIG: 1142 + value = config_buf(gadget->speed, req->buf, 1143 + wValue >> 8, 1144 + wValue & 0xff, 1145 + gadget->is_otg); 1146 + if (value >= 0) 1147 + value = min(wLength, (u16) value); 1148 + break; 1149 + 1150 + case USB_DT_STRING: 1151 + value = usb_gadget_get_string(&stringtab, 1152 + wValue & 0xff, req->buf); 1153 + if (value >= 0) 1154 + value = min(wLength, (u16) value); 1155 + break; 1156 + } 1157 + break; 1158 + 1159 + case USB_REQ_SET_CONFIGURATION: 1160 + if (ctrl->bRequestType != 0) 1161 + break; 1162 + if (gadget->a_hnp_support) 1163 + DBG(dev, "HNP available\n"); 1164 + else if (gadget->a_alt_hnp_support) 1165 + DBG(dev, "HNP needs a different root port\n"); 1166 + value = printer_set_config(dev, wValue); 1167 + break; 1168 + case USB_REQ_GET_CONFIGURATION: 1169 + if (ctrl->bRequestType != USB_DIR_IN) 1170 + break; 1171 + *(u8 *)req->buf = dev->config; 1172 + value = min(wLength, (u16) 1); 1173 + break; 1174 + 1175 + case USB_REQ_SET_INTERFACE: 1176 + if (ctrl->bRequestType != USB_RECIP_INTERFACE || 1177 + !dev->config) 1178 + break; 1179 + 1180 + value = set_interface(dev, PRINTER_INTERFACE); 1181 + break; 1182 + case USB_REQ_GET_INTERFACE: 1183 + if (ctrl->bRequestType != 1184 + (USB_DIR_IN|USB_RECIP_INTERFACE) 1185 + || !dev->config) 1186 + break; 1187 + 1188 + *(u8 *)req->buf = dev->interface; 1189 + value = min(wLength, (u16) 1); 1190 + break; 1191 + 1192 + default: 1193 + goto unknown; 1194 + } 1195 + break; 1196 + 1197 + case USB_TYPE_CLASS: 1198 + switch (ctrl->bRequest) { 1199 + case 0: /* Get the IEEE-1284 PNP String */ 1200 + /* Only one printer interface is supported. */ 1201 + if ((wIndex>>8) != PRINTER_INTERFACE) 1202 + break; 1203 + 1204 + value = (pnp_string[0]<<8)|pnp_string[1]; 1205 + memcpy(req->buf, pnp_string, value); 1206 + DBG(dev, "1284 PNP String: %x %s\n", value, 1207 + &pnp_string[2]); 1208 + break; 1209 + 1210 + case 1: /* Get Port Status */ 1211 + /* Only one printer interface is supported. */ 1212 + if (wIndex != PRINTER_INTERFACE) 1213 + break; 1214 + 1215 + *(u8 *)req->buf = dev->printer_status; 1216 + value = min(wLength, (u16) 1); 1217 + break; 1218 + 1219 + case 2: /* Soft Reset */ 1220 + /* Only one printer interface is supported. */ 1221 + if (wIndex != PRINTER_INTERFACE) 1222 + break; 1223 + 1224 + printer_soft_reset(dev); 1225 + 1226 + value = 0; 1227 + break; 1228 + 1229 + default: 1230 + goto unknown; 1231 + } 1232 + break; 1233 + 1234 + default: 1235 + unknown: 1236 + VDBG(dev, 1237 + "unknown ctrl req%02x.%02x v%04x i%04x l%d\n", 1238 + ctrl->bRequestType, ctrl->bRequest, 1239 + wValue, wIndex, wLength); 1240 + break; 1241 + } 1242 + 1243 + /* respond with data transfer before status phase? */ 1244 + if (value >= 0) { 1245 + req->length = value; 1246 + req->zero = value < wLength 1247 + && (value % gadget->ep0->maxpacket) == 0; 1248 + value = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC); 1249 + if (value < 0) { 1250 + DBG(dev, "ep_queue --> %d\n", value); 1251 + req->status = 0; 1252 + printer_setup_complete(gadget->ep0, req); 1253 + } 1254 + } 1255 + 1256 + /* host either stalls (value < 0) or reports success */ 1257 + return value; 1258 + } 1259 + 1260 + static void 1261 + printer_disconnect(struct usb_gadget *gadget) 1262 + { 1263 + struct printer_dev *dev = get_gadget_data(gadget); 1264 + unsigned long flags; 1265 + 1266 + DBG(dev, "%s\n", __FUNCTION__); 1267 + 1268 + spin_lock_irqsave(&dev->lock, flags); 1269 + 1270 + printer_reset_interface(dev); 1271 + 1272 + spin_unlock_irqrestore(&dev->lock, flags); 1273 + } 1274 + 1275 + static void 1276 + printer_unbind(struct usb_gadget *gadget) 1277 + { 1278 + struct printer_dev *dev = get_gadget_data(gadget); 1279 + struct usb_request *req; 1280 + 1281 + 1282 + DBG(dev, "%s\n", __FUNCTION__); 1283 + 1284 + /* Remove sysfs files */ 1285 + device_destroy(usb_gadget_class, g_printer_devno); 1286 + 1287 + /* Remove Character Device */ 1288 + cdev_del(&dev->printer_cdev); 1289 + 1290 + /* we must already have been disconnected ... no i/o may be active */ 1291 + WARN_ON(!list_empty(&dev->tx_reqs_active)); 1292 + WARN_ON(!list_empty(&dev->rx_reqs_active)); 1293 + 1294 + /* Free all memory for this driver. */ 1295 + while (!list_empty(&dev->tx_reqs)) { 1296 + req = container_of(dev->tx_reqs.next, struct usb_request, 1297 + list); 1298 + list_del(&req->list); 1299 + printer_req_free(dev->in_ep, req); 1300 + } 1301 + 1302 + if (dev->current_rx_req != NULL); 1303 + printer_req_free(dev->out_ep, dev->current_rx_req); 1304 + 1305 + while (!list_empty(&dev->rx_reqs)) { 1306 + req = container_of(dev->rx_reqs.next, 1307 + struct usb_request, list); 1308 + list_del(&req->list); 1309 + printer_req_free(dev->out_ep, req); 1310 + } 1311 + 1312 + while (!list_empty(&dev->rx_buffers)) { 1313 + req = container_of(dev->rx_buffers.next, 1314 + struct usb_request, list); 1315 + list_del(&req->list); 1316 + printer_req_free(dev->out_ep, req); 1317 + } 1318 + 1319 + if (dev->req) { 1320 + printer_req_free(gadget->ep0, dev->req); 1321 + dev->req = NULL; 1322 + } 1323 + 1324 + set_gadget_data(gadget, NULL); 1325 + } 1326 + 1327 + static int __init 1328 + printer_bind(struct usb_gadget *gadget) 1329 + { 1330 + struct printer_dev *dev; 1331 + struct usb_ep *in_ep, *out_ep; 1332 + int status = -ENOMEM; 1333 + int gcnum; 1334 + size_t len; 1335 + u32 i; 1336 + struct usb_request *req; 1337 + 1338 + dev = &usb_printer_gadget; 1339 + 1340 + 1341 + /* Setup the sysfs files for the printer gadget. */ 1342 + dev->pdev = device_create(usb_gadget_class, NULL, g_printer_devno, 1343 + "g_printer"); 1344 + if (IS_ERR(dev->pdev)) { 1345 + ERROR(dev, "Failed to create device: g_printer\n"); 1346 + goto fail; 1347 + } 1348 + 1349 + /* 1350 + * Register a character device as an interface to a user mode 1351 + * program that handles the printer specific functionality. 1352 + */ 1353 + cdev_init(&dev->printer_cdev, &printer_io_operations); 1354 + dev->printer_cdev.owner = THIS_MODULE; 1355 + status = cdev_add(&dev->printer_cdev, g_printer_devno, 1); 1356 + if (status) { 1357 + ERROR(dev, "Failed to open char device\n"); 1358 + goto fail; 1359 + } 1360 + 1361 + if (gadget_is_sa1100(gadget)) { 1362 + /* hardware can't write zero length packets. */ 1363 + ERROR(dev, "SA1100 controller is unsupport by this driver\n"); 1364 + goto fail; 1365 + } 1366 + 1367 + gcnum = usb_gadget_controller_number(gadget); 1368 + if (gcnum >= 0) { 1369 + device_desc.bcdDevice = cpu_to_le16(0x0200 + gcnum); 1370 + } else { 1371 + dev_warn(&gadget->dev, "controller '%s' not recognized\n", 1372 + gadget->name); 1373 + /* unrecognized, but safe unless bulk is REALLY quirky */ 1374 + device_desc.bcdDevice = 1375 + __constant_cpu_to_le16(0xFFFF); 1376 + } 1377 + snprintf(manufacturer, sizeof(manufacturer), "%s %s with %s", 1378 + init_utsname()->sysname, init_utsname()->release, 1379 + gadget->name); 1380 + 1381 + device_desc.idVendor = 1382 + __constant_cpu_to_le16(PRINTER_VENDOR_NUM); 1383 + device_desc.idProduct = 1384 + __constant_cpu_to_le16(PRINTER_PRODUCT_NUM); 1385 + 1386 + /* support optional vendor/distro customization */ 1387 + if (idVendor) { 1388 + if (!idProduct) { 1389 + dev_err(&gadget->dev, "idVendor needs idProduct!\n"); 1390 + return -ENODEV; 1391 + } 1392 + device_desc.idVendor = cpu_to_le16(idVendor); 1393 + device_desc.idProduct = cpu_to_le16(idProduct); 1394 + if (bcdDevice) 1395 + device_desc.bcdDevice = cpu_to_le16(bcdDevice); 1396 + } 1397 + 1398 + if (iManufacturer) 1399 + strlcpy(manufacturer, iManufacturer, sizeof manufacturer); 1400 + 1401 + if (iProduct) 1402 + strlcpy(product_desc, iProduct, sizeof product_desc); 1403 + 1404 + if (iSerialNum) 1405 + strlcpy(serial_num, iSerialNum, sizeof serial_num); 1406 + 1407 + if (iPNPstring) 1408 + strlcpy(&pnp_string[2], iPNPstring, (sizeof pnp_string)-2); 1409 + 1410 + len = strlen(pnp_string); 1411 + pnp_string[0] = (len >> 8) & 0xFF; 1412 + pnp_string[1] = len & 0xFF; 1413 + 1414 + /* all we really need is bulk IN/OUT */ 1415 + usb_ep_autoconfig_reset(gadget); 1416 + in_ep = usb_ep_autoconfig(gadget, &fs_ep_in_desc); 1417 + if (!in_ep) { 1418 + autoconf_fail: 1419 + dev_err(&gadget->dev, "can't autoconfigure on %s\n", 1420 + gadget->name); 1421 + return -ENODEV; 1422 + } 1423 + in_ep->driver_data = in_ep; /* claim */ 1424 + 1425 + out_ep = usb_ep_autoconfig(gadget, &fs_ep_out_desc); 1426 + if (!out_ep) 1427 + goto autoconf_fail; 1428 + out_ep->driver_data = out_ep; /* claim */ 1429 + 1430 + #ifdef CONFIG_USB_GADGET_DUALSPEED 1431 + /* assumes ep0 uses the same value for both speeds ... */ 1432 + dev_qualifier.bMaxPacketSize0 = device_desc.bMaxPacketSize0; 1433 + 1434 + /* and that all endpoints are dual-speed */ 1435 + hs_ep_in_desc.bEndpointAddress = fs_ep_in_desc.bEndpointAddress; 1436 + hs_ep_out_desc.bEndpointAddress = fs_ep_out_desc.bEndpointAddress; 1437 + #endif /* DUALSPEED */ 1438 + 1439 + device_desc.bMaxPacketSize0 = gadget->ep0->maxpacket; 1440 + usb_gadget_set_selfpowered(gadget); 1441 + 1442 + if (gadget->is_otg) { 1443 + otg_desc.bmAttributes |= USB_OTG_HNP, 1444 + config_desc.bmAttributes |= USB_CONFIG_ATT_WAKEUP; 1445 + config_desc.bMaxPower = 4; 1446 + } 1447 + 1448 + spin_lock_init(&dev->lock); 1449 + spin_lock_init(&dev->lock_printer_io); 1450 + INIT_LIST_HEAD(&dev->tx_reqs); 1451 + INIT_LIST_HEAD(&dev->tx_reqs_active); 1452 + INIT_LIST_HEAD(&dev->rx_reqs); 1453 + INIT_LIST_HEAD(&dev->rx_reqs_active); 1454 + INIT_LIST_HEAD(&dev->rx_buffers); 1455 + init_waitqueue_head(&dev->rx_wait); 1456 + init_waitqueue_head(&dev->tx_wait); 1457 + init_waitqueue_head(&dev->tx_flush_wait); 1458 + 1459 + dev->config = 0; 1460 + dev->interface = -1; 1461 + dev->printer_cdev_open = 0; 1462 + dev->printer_status = PRINTER_NOT_ERROR; 1463 + dev->current_rx_req = NULL; 1464 + dev->current_rx_bytes = 0; 1465 + dev->current_rx_buf = NULL; 1466 + 1467 + dev->in_ep = in_ep; 1468 + dev->out_ep = out_ep; 1469 + 1470 + /* preallocate control message data and buffer */ 1471 + dev->req = printer_req_alloc(gadget->ep0, USB_DESC_BUFSIZE, 1472 + GFP_KERNEL); 1473 + if (!dev->req) { 1474 + status = -ENOMEM; 1475 + goto fail; 1476 + } 1477 + 1478 + for (i = 0; i < QLEN; i++) { 1479 + req = printer_req_alloc(dev->in_ep, USB_BUFSIZE, GFP_KERNEL); 1480 + if (!req) { 1481 + while (!list_empty(&dev->tx_reqs)) { 1482 + req = container_of(dev->tx_reqs.next, 1483 + struct usb_request, list); 1484 + list_del(&req->list); 1485 + printer_req_free(dev->in_ep, req); 1486 + } 1487 + return -ENOMEM; 1488 + } 1489 + list_add(&req->list, &dev->tx_reqs); 1490 + } 1491 + 1492 + for (i = 0; i < QLEN; i++) { 1493 + req = printer_req_alloc(dev->out_ep, USB_BUFSIZE, GFP_KERNEL); 1494 + if (!req) { 1495 + while (!list_empty(&dev->rx_reqs)) { 1496 + req = container_of(dev->rx_reqs.next, 1497 + struct usb_request, list); 1498 + list_del(&req->list); 1499 + printer_req_free(dev->out_ep, req); 1500 + } 1501 + return -ENOMEM; 1502 + } 1503 + list_add(&req->list, &dev->rx_reqs); 1504 + } 1505 + 1506 + dev->req->complete = printer_setup_complete; 1507 + 1508 + /* finish hookup to lower layer ... */ 1509 + dev->gadget = gadget; 1510 + set_gadget_data(gadget, dev); 1511 + gadget->ep0->driver_data = dev; 1512 + 1513 + INFO(dev, "%s, version: " DRIVER_VERSION "\n", driver_desc); 1514 + INFO(dev, "using %s, OUT %s IN %s\n", gadget->name, out_ep->name, 1515 + in_ep->name); 1516 + 1517 + return 0; 1518 + 1519 + fail: 1520 + printer_unbind(gadget); 1521 + return status; 1522 + } 1523 + 1524 + /*-------------------------------------------------------------------------*/ 1525 + 1526 + static struct usb_gadget_driver printer_driver = { 1527 + .speed = DEVSPEED, 1528 + 1529 + .function = (char *) driver_desc, 1530 + .bind = printer_bind, 1531 + .unbind = printer_unbind, 1532 + 1533 + .setup = printer_setup, 1534 + .disconnect = printer_disconnect, 1535 + 1536 + .driver = { 1537 + .name = (char *) shortname, 1538 + .owner = THIS_MODULE, 1539 + }, 1540 + }; 1541 + 1542 + MODULE_DESCRIPTION(DRIVER_DESC); 1543 + MODULE_AUTHOR("Craig Nadler"); 1544 + MODULE_LICENSE("GPL"); 1545 + 1546 + static int __init 1547 + init(void) 1548 + { 1549 + int status; 1550 + 1551 + usb_gadget_class = class_create(THIS_MODULE, "usb_printer_gadget"); 1552 + if (IS_ERR(usb_gadget_class)) { 1553 + status = PTR_ERR(usb_gadget_class); 1554 + ERROR(dev, "unable to create usb_gadget class %d\n", status); 1555 + return status; 1556 + } 1557 + 1558 + status = alloc_chrdev_region(&g_printer_devno, 0, 1, 1559 + "USB printer gadget"); 1560 + if (status) { 1561 + ERROR(dev, "alloc_chrdev_region %d\n", status); 1562 + class_destroy(usb_gadget_class); 1563 + return status; 1564 + } 1565 + 1566 + status = usb_gadget_register_driver(&printer_driver); 1567 + if (status) { 1568 + class_destroy(usb_gadget_class); 1569 + unregister_chrdev_region(g_printer_devno, 1); 1570 + DBG(dev, "usb_gadget_register_driver %x\n", status); 1571 + } 1572 + 1573 + return status; 1574 + } 1575 + module_init(init); 1576 + 1577 + static void __exit 1578 + cleanup(void) 1579 + { 1580 + int status; 1581 + 1582 + spin_lock(&usb_printer_gadget.lock_printer_io); 1583 + class_destroy(usb_gadget_class); 1584 + unregister_chrdev_region(g_printer_devno, 2); 1585 + 1586 + status = usb_gadget_unregister_driver(&printer_driver); 1587 + if (status) 1588 + ERROR(dev, "usb_gadget_unregister_driver %x\n", status); 1589 + 1590 + spin_unlock(&usb_printer_gadget.lock_printer_io); 1591 + } 1592 + module_exit(cleanup);
+67 -74
drivers/usb/gadget/pxa2xx_udc.c
··· 24 24 * 25 25 */ 26 26 27 - // #define VERBOSE DBG_VERBOSE 27 + /* #define VERBOSE_DEBUG */ 28 28 29 29 #include <linux/device.h> 30 30 #include <linux/module.h> ··· 38 38 #include <linux/timer.h> 39 39 #include <linux/list.h> 40 40 #include <linux/interrupt.h> 41 - #include <linux/proc_fs.h> 42 41 #include <linux/mm.h> 43 42 #include <linux/platform_device.h> 44 43 #include <linux/dma-mapping.h> 45 44 #include <linux/irq.h> 46 45 #include <linux/clk.h> 47 46 #include <linux/err.h> 47 + #include <linux/seq_file.h> 48 + #include <linux/debugfs.h> 48 49 49 50 #include <asm/byteorder.h> 50 51 #include <asm/dma.h> ··· 128 127 { 129 128 struct pxa2xx_udc_mach_info *mach = the_controller->mach; 130 129 131 - if (mach->gpio_vbus) 132 - return gpio_get_value(mach->gpio_vbus); 130 + if (mach->gpio_vbus) { 131 + int value = gpio_get_value(mach->gpio_vbus); 132 + return mach->gpio_vbus_inverted ? !value : value; 133 + } 133 134 if (mach->udc_is_connected) 134 135 return mach->udc_is_connected(); 135 136 return 1; ··· 680 677 681 678 /* kickstart this i/o queue? */ 682 679 if (list_empty(&ep->queue) && !ep->stopped) { 683 - if (ep->desc == 0 /* ep0 */) { 680 + if (ep->desc == NULL/* ep0 */) { 684 681 unsigned length = _req->length; 685 682 686 683 switch (dev->ep0state) { ··· 734 731 } 735 732 736 733 /* pio or dma irq handler advances the queue. */ 737 - if (likely (req != 0)) 734 + if (likely(req != NULL)) 738 735 list_add_tail(&req->queue, &ep->queue); 739 736 local_irq_restore(flags); 740 737 ··· 994 991 995 992 /*-------------------------------------------------------------------------*/ 996 993 997 - #ifdef CONFIG_USB_GADGET_DEBUG_FILES 998 - 999 - static const char proc_node_name [] = "driver/udc"; 994 + #ifdef CONFIG_USB_GADGET_DEBUG_FS 1000 995 1001 996 static int 1002 - udc_proc_read(char *page, char **start, off_t off, int count, 1003 - int *eof, void *_dev) 997 + udc_seq_show(struct seq_file *m, void *d) 1004 998 { 1005 - char *buf = page; 1006 - struct pxa2xx_udc *dev = _dev; 1007 - char *next = buf; 1008 - unsigned size = count; 999 + struct pxa2xx_udc *dev = m->private; 1009 1000 unsigned long flags; 1010 - int i, t; 1001 + int i; 1011 1002 u32 tmp; 1012 - 1013 - if (off != 0) 1014 - return 0; 1015 1003 1016 1004 local_irq_save(flags); 1017 1005 1018 1006 /* basic device status */ 1019 - t = scnprintf(next, size, DRIVER_DESC "\n" 1007 + seq_printf(m, DRIVER_DESC "\n" 1020 1008 "%s version: %s\nGadget driver: %s\nHost %s\n\n", 1021 1009 driver_name, DRIVER_VERSION SIZE_STR "(pio)", 1022 1010 dev->driver ? dev->driver->driver.name : "(none)", 1023 1011 is_vbus_present() ? "full speed" : "disconnected"); 1024 - size -= t; 1025 - next += t; 1026 1012 1027 1013 /* registers for device and ep0 */ 1028 - t = scnprintf(next, size, 1014 + seq_printf(m, 1029 1015 "uicr %02X.%02X, usir %02X.%02x, ufnr %02X.%02X\n", 1030 1016 UICR1, UICR0, USIR1, USIR0, UFNRH, UFNRL); 1031 - size -= t; 1032 - next += t; 1033 1017 1034 1018 tmp = UDCCR; 1035 - t = scnprintf(next, size, 1019 + seq_printf(m, 1036 1020 "udccr %02X =%s%s%s%s%s%s%s%s\n", tmp, 1037 1021 (tmp & UDCCR_REM) ? " rem" : "", 1038 1022 (tmp & UDCCR_RSTIR) ? " rstir" : "", ··· 1029 1039 (tmp & UDCCR_RSM) ? " rsm" : "", 1030 1040 (tmp & UDCCR_UDA) ? " uda" : "", 1031 1041 (tmp & UDCCR_UDE) ? " ude" : ""); 1032 - size -= t; 1033 - next += t; 1034 1042 1035 1043 tmp = UDCCS0; 1036 - t = scnprintf(next, size, 1044 + seq_printf(m, 1037 1045 "udccs0 %02X =%s%s%s%s%s%s%s%s\n", tmp, 1038 1046 (tmp & UDCCS0_SA) ? " sa" : "", 1039 1047 (tmp & UDCCS0_RNE) ? " rne" : "", ··· 1041 1053 (tmp & UDCCS0_FTF) ? " ftf" : "", 1042 1054 (tmp & UDCCS0_IPR) ? " ipr" : "", 1043 1055 (tmp & UDCCS0_OPR) ? " opr" : ""); 1044 - size -= t; 1045 - next += t; 1046 1056 1047 1057 if (dev->has_cfr) { 1048 1058 tmp = UDCCFR; 1049 - t = scnprintf(next, size, 1059 + seq_printf(m, 1050 1060 "udccfr %02X =%s%s\n", tmp, 1051 1061 (tmp & UDCCFR_AREN) ? " aren" : "", 1052 1062 (tmp & UDCCFR_ACM) ? " acm" : ""); 1053 - size -= t; 1054 - next += t; 1055 1063 } 1056 1064 1057 1065 if (!is_vbus_present() || !dev->driver) 1058 1066 goto done; 1059 1067 1060 - t = scnprintf(next, size, "ep0 IN %lu/%lu, OUT %lu/%lu\nirqs %lu\n\n", 1068 + seq_printf(m, "ep0 IN %lu/%lu, OUT %lu/%lu\nirqs %lu\n\n", 1061 1069 dev->stats.write.bytes, dev->stats.write.ops, 1062 1070 dev->stats.read.bytes, dev->stats.read.ops, 1063 1071 dev->stats.irqs); 1064 - size -= t; 1065 - next += t; 1066 1072 1067 1073 /* dump endpoint queues */ 1068 1074 for (i = 0; i < PXA_UDC_NUM_ENDPOINTS; i++) { ··· 1064 1082 struct pxa2xx_request *req; 1065 1083 1066 1084 if (i != 0) { 1067 - const struct usb_endpoint_descriptor *d; 1085 + const struct usb_endpoint_descriptor *desc; 1068 1086 1069 - d = ep->desc; 1070 - if (!d) 1087 + desc = ep->desc; 1088 + if (!desc) 1071 1089 continue; 1072 1090 tmp = *dev->ep [i].reg_udccs; 1073 - t = scnprintf(next, size, 1091 + seq_printf(m, 1074 1092 "%s max %d %s udccs %02x irqs %lu\n", 1075 - ep->ep.name, le16_to_cpu (d->wMaxPacketSize), 1093 + ep->ep.name, le16_to_cpu(desc->wMaxPacketSize), 1076 1094 "pio", tmp, ep->pio_irqs); 1077 1095 /* TODO translate all five groups of udccs bits! */ 1078 1096 1079 1097 } else /* ep0 should only have one transfer queued */ 1080 - t = scnprintf(next, size, "ep0 max 16 pio irqs %lu\n", 1098 + seq_printf(m, "ep0 max 16 pio irqs %lu\n", 1081 1099 ep->pio_irqs); 1082 - if (t <= 0 || t > size) 1083 - goto done; 1084 - size -= t; 1085 - next += t; 1086 1100 1087 1101 if (list_empty(&ep->queue)) { 1088 - t = scnprintf(next, size, "\t(nothing queued)\n"); 1089 - if (t <= 0 || t > size) 1090 - goto done; 1091 - size -= t; 1092 - next += t; 1102 + seq_printf(m, "\t(nothing queued)\n"); 1093 1103 continue; 1094 1104 } 1095 1105 list_for_each_entry(req, &ep->queue, queue) { 1096 - t = scnprintf(next, size, 1106 + seq_printf(m, 1097 1107 "\treq %p len %d/%d buf %p\n", 1098 1108 &req->req, req->req.actual, 1099 1109 req->req.length, req->req.buf); 1100 - if (t <= 0 || t > size) 1101 - goto done; 1102 - size -= t; 1103 - next += t; 1104 1110 } 1105 1111 } 1106 1112 1107 1113 done: 1108 1114 local_irq_restore(flags); 1109 - *eof = 1; 1110 - return count - size; 1115 + return 0; 1111 1116 } 1112 1117 1113 - #define create_proc_files() \ 1114 - create_proc_read_entry(proc_node_name, 0, NULL, udc_proc_read, dev) 1115 - #define remove_proc_files() \ 1116 - remove_proc_entry(proc_node_name, NULL) 1118 + static int 1119 + udc_debugfs_open(struct inode *inode, struct file *file) 1120 + { 1121 + return single_open(file, udc_seq_show, inode->i_private); 1122 + } 1123 + 1124 + static const struct file_operations debug_fops = { 1125 + .open = udc_debugfs_open, 1126 + .read = seq_read, 1127 + .llseek = seq_lseek, 1128 + .release = single_release, 1129 + .owner = THIS_MODULE, 1130 + }; 1131 + 1132 + #define create_debug_files(dev) \ 1133 + do { \ 1134 + dev->debugfs_udc = debugfs_create_file(dev->gadget.name, \ 1135 + S_IRUGO, NULL, dev, &debug_fops); \ 1136 + } while (0) 1137 + #define remove_debug_files(dev) \ 1138 + do { \ 1139 + if (dev->debugfs_udc) \ 1140 + debugfs_remove(dev->debugfs_udc); \ 1141 + } while (0) 1117 1142 1118 1143 #else /* !CONFIG_USB_GADGET_DEBUG_FILES */ 1119 1144 1120 - #define create_proc_files() do {} while (0) 1121 - #define remove_proc_files() do {} while (0) 1145 + #define create_debug_files(dev) do {} while (0) 1146 + #define remove_debug_files(dev) do {} while (0) 1122 1147 1123 1148 #endif /* CONFIG_USB_GADGET_DEBUG_FILES */ 1124 1149 ··· 1334 1345 local_irq_enable(); 1335 1346 1336 1347 driver->unbind(&dev->gadget); 1348 + dev->gadget.dev.driver = NULL; 1337 1349 dev->driver = NULL; 1338 1350 1339 1351 device_del (&dev->gadget.dev); ··· 1386 1396 { 1387 1397 struct pxa2xx_udc *dev = _dev; 1388 1398 int vbus = gpio_get_value(dev->mach->gpio_vbus); 1399 + 1400 + if (dev->mach->gpio_vbus_inverted) 1401 + vbus = !vbus; 1389 1402 1390 1403 pxa2xx_udc_vbus_session(&dev->gadget, vbus); 1391 1404 return IRQ_HANDLED; ··· 2092 2099 /* insist on Intel/ARM/XScale */ 2093 2100 asm("mrc%? p15, 0, %0, c0, c0" : "=r" (chiprev)); 2094 2101 if ((chiprev & CP15R0_VENDOR_MASK) != CP15R0_XSCALE_VALUE) { 2095 - printk(KERN_ERR "%s: not XScale!\n", driver_name); 2102 + pr_err("%s: not XScale!\n", driver_name); 2096 2103 return -ENODEV; 2097 2104 } 2098 2105 ··· 2121 2128 break; 2122 2129 #endif 2123 2130 default: 2124 - printk(KERN_ERR "%s: unrecognized processor: %08x\n", 2131 + pr_err("%s: unrecognized processor: %08x\n", 2125 2132 driver_name, chiprev); 2126 2133 /* iop3xx, ixp4xx, ... */ 2127 2134 return -ENODEV; ··· 2192 2199 retval = request_irq(irq, pxa2xx_udc_irq, 2193 2200 IRQF_DISABLED, driver_name, dev); 2194 2201 if (retval != 0) { 2195 - printk(KERN_ERR "%s: can't get irq %d, err %d\n", 2202 + pr_err("%s: can't get irq %d, err %d\n", 2196 2203 driver_name, irq, retval); 2197 2204 goto err_irq1; 2198 2205 } ··· 2205 2212 IRQF_DISABLED | IRQF_SAMPLE_RANDOM, 2206 2213 driver_name, dev); 2207 2214 if (retval != 0) { 2208 - printk(KERN_ERR "%s: can't get irq %i, err %d\n", 2215 + pr_err("%s: can't get irq %i, err %d\n", 2209 2216 driver_name, LUBBOCK_USB_DISC_IRQ, retval); 2210 2217 lubbock_fail0: 2211 2218 goto err_irq_lub; ··· 2215 2222 IRQF_DISABLED | IRQF_SAMPLE_RANDOM, 2216 2223 driver_name, dev); 2217 2224 if (retval != 0) { 2218 - printk(KERN_ERR "%s: can't get irq %i, err %d\n", 2225 + pr_err("%s: can't get irq %i, err %d\n", 2219 2226 driver_name, LUBBOCK_USB_IRQ, retval); 2220 2227 free_irq(LUBBOCK_USB_DISC_IRQ, dev); 2221 2228 goto lubbock_fail0; ··· 2228 2235 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, 2229 2236 driver_name, dev); 2230 2237 if (retval != 0) { 2231 - printk(KERN_ERR "%s: can't get irq %i, err %d\n", 2238 + pr_err("%s: can't get irq %i, err %d\n", 2232 2239 driver_name, vbus_irq, retval); 2233 2240 goto err_vbus_irq; 2234 2241 } 2235 2242 } 2236 - create_proc_files(); 2243 + create_debug_files(dev); 2237 2244 2238 2245 return 0; 2239 2246 ··· 2270 2277 return -EBUSY; 2271 2278 2272 2279 udc_disable(dev); 2273 - remove_proc_files(); 2280 + remove_debug_files(dev); 2274 2281 2275 2282 if (dev->got_irq) { 2276 2283 free_irq(platform_get_irq(pdev, 0), dev); ··· 2354 2361 2355 2362 static int __init udc_init(void) 2356 2363 { 2357 - printk(KERN_INFO "%s: version %s\n", driver_name, DRIVER_VERSION); 2364 + pr_info("%s: version %s\n", driver_name, DRIVER_VERSION); 2358 2365 return platform_driver_probe(&udc_driver, pxa2xx_udc_probe); 2359 2366 } 2360 2367 module_init(udc_init);
+15 -10
drivers/usb/gadget/pxa2xx_udc.h
··· 129 129 struct pxa2xx_udc_mach_info *mach; 130 130 u64 dma_mask; 131 131 struct pxa2xx_ep ep [PXA_UDC_NUM_ENDPOINTS]; 132 + 133 + #ifdef CONFIG_USB_GADGET_DEBUG_FS 134 + struct dentry *debugfs_udc; 135 + #endif 132 136 }; 133 137 134 138 /*-------------------------------------------------------------------------*/ ··· 155 151 #define DBG_NOISY 3 /* ... even more: request level */ 156 152 #define DBG_VERY_NOISY 4 /* ... even more: packet level */ 157 153 154 + #define DMSG(stuff...) pr_debug("udc: " stuff) 155 + 158 156 #ifdef DEBUG 157 + 158 + static int is_vbus_present(void); 159 159 160 160 static const char *state_name[] = { 161 161 "EP0_IDLE", ··· 167 159 "EP0_END_XFER", "EP0_STALL" 168 160 }; 169 161 170 - #define DMSG(stuff...) printk(KERN_DEBUG "udc: " stuff) 171 - 172 - #ifdef VERBOSE 162 + #ifdef VERBOSE_DEBUG 173 163 # define UDC_DEBUG DBG_VERBOSE 174 164 #else 175 165 # define UDC_DEBUG DBG_NORMAL ··· 213 207 unsigned i; 214 208 215 209 DMSG("%s %s, uicr %02X.%02X, usir %02X.%02x, ufnr %02X.%02X\n", 216 - is_usb_connected() ? "host " : "disconnected", 210 + is_vbus_present() ? "host " : "disconnected", 217 211 state_name[dev->ep0state], 218 212 UICR1, UICR0, USIR1, USIR0, UFNRH, UFNRL); 219 213 dump_udccr("udccr"); ··· 230 224 } else 231 225 DMSG("ep0 driver '%s'\n", dev->driver->driver.name); 232 226 233 - if (!is_usb_connected()) 227 + if (!is_vbus_present()) 234 228 return; 235 229 236 230 dump_udccs0 ("udccs0"); ··· 239 233 dev->stats.read.bytes, dev->stats.read.ops); 240 234 241 235 for (i = 1; i < PXA_UDC_NUM_ENDPOINTS; i++) { 242 - if (dev->ep [i].desc == 0) 236 + if (dev->ep [i].desc == NULL) 243 237 continue; 244 238 DMSG ("udccs%d = %02x\n", i, *dev->ep->reg_udccs); 245 239 } 246 240 } 247 241 248 242 #else 249 - 250 - #define DMSG(stuff...) do{}while(0) 251 243 252 244 #define dump_udccr(x) do{}while(0) 253 245 #define dump_udccs0(x) do{}while(0) ··· 257 253 258 254 #define DBG(lvl, stuff...) do{if ((lvl) <= UDC_DEBUG) DMSG(stuff);}while(0) 259 255 260 - #define WARN(stuff...) printk(KERN_WARNING "udc: " stuff) 261 - #define INFO(stuff...) printk(KERN_INFO "udc: " stuff) 256 + #define ERR(stuff...) pr_err("udc: " stuff) 257 + #define WARN(stuff...) pr_warning("udc: " stuff) 258 + #define INFO(stuff...) pr_info("udc: " stuff) 262 259 263 260 264 261 #endif /* __LINUX_USB_GADGET_PXA2XX_H */
+8 -12
drivers/usb/gadget/rndis.c
··· 53 53 */ 54 54 55 55 #if 0 56 - #define DBG(str,args...) do { \ 57 - if (rndis_debug) \ 58 - printk(KERN_DEBUG str , ## args ); \ 59 - } while (0) 60 56 static int rndis_debug = 0; 61 - 62 57 module_param (rndis_debug, int, 0); 63 58 MODULE_PARM_DESC (rndis_debug, "enable debugging"); 64 - 65 59 #else 66 - 67 60 #define rndis_debug 0 68 - #define DBG(str,args...) do{}while(0) 69 61 #endif 62 + 63 + #define DBG(str,args...) do { \ 64 + if (rndis_debug) \ 65 + pr_debug(str , ## args); \ 66 + } while (0) 70 67 71 68 #define RNDIS_MAX_CONFIGS 1 72 69 ··· 676 679 #endif 677 680 678 681 default: 679 - printk (KERN_WARNING "%s: query unknown OID 0x%08X\n", 682 + pr_warning("%s: query unknown OID 0x%08X\n", 680 683 __FUNCTION__, OID); 681 684 } 682 685 if (retval < 0) ··· 801 804 #endif /* RNDIS_PM */ 802 805 803 806 default: 804 - printk (KERN_WARNING "%s: set unknown OID 0x%08X, size %d\n", 807 + pr_warning("%s: set unknown OID 0x%08X, size %d\n", 805 808 __FUNCTION__, OID, buf_len); 806 809 } 807 810 ··· 1123 1126 * In one case those messages seemed to relate to the host 1124 1127 * suspending itself. 1125 1128 */ 1126 - printk (KERN_WARNING 1127 - "%s: unknown RNDIS message 0x%08X len %d\n", 1129 + pr_warning("%s: unknown RNDIS message 0x%08X len %d\n", 1128 1130 __FUNCTION__ , MsgType, MsgLength); 1129 1131 { 1130 1132 unsigned i;
+2 -2
drivers/usb/gadget/s3c2410_udc.c
··· 893 893 /* 894 894 * s3c2410_udc_irq - interrupt handler 895 895 */ 896 - static irqreturn_t s3c2410_udc_irq(int irq, void *_dev) 896 + static irqreturn_t s3c2410_udc_irq(int dummy, void *_dev) 897 897 { 898 898 struct s3c2410_udc *dev = _dev; 899 899 int usb_status; ··· 1016 1016 } 1017 1017 } 1018 1018 1019 - dprintk(DEBUG_VERBOSE, "irq: %d s3c2410_udc_done.\n", irq); 1019 + dprintk(DEBUG_VERBOSE, "irq: %d s3c2410_udc_done.\n", IRQ_USBD); 1020 1020 1021 1021 /* Restore old index */ 1022 1022 udc_write(idx, S3C2410_UDC_INDEX_REG);
+79 -74
drivers/usb/gadget/serial.c
··· 89 89 #endif 90 90 91 91 #define gs_debug(format, arg...) \ 92 - do { if (debug) printk(KERN_DEBUG format, ## arg); } while(0) 92 + do { if (debug) pr_debug(format, ## arg); } while (0) 93 93 #define gs_debug_level(level, format, arg...) \ 94 - do { if (debug>=level) printk(KERN_DEBUG format, ## arg); } while(0) 94 + do { if (debug >= level) pr_debug(format, ## arg); } while (0) 95 95 96 96 97 97 /* Thanks to NetChip Technologies for donating this product ID. ··· 553 553 554 554 retval = usb_gadget_register_driver(&gs_gadget_driver); 555 555 if (retval) { 556 - printk(KERN_ERR "gs_module_init: cannot register gadget driver, ret=%d\n", retval); 556 + pr_err("gs_module_init: cannot register gadget driver, " 557 + "ret=%d\n", retval); 557 558 return retval; 558 559 } 559 560 ··· 580 579 if (retval) { 581 580 usb_gadget_unregister_driver(&gs_gadget_driver); 582 581 put_tty_driver(gs_tty_driver); 583 - printk(KERN_ERR "gs_module_init: cannot register tty driver, ret=%d\n", retval); 582 + pr_err("gs_module_init: cannot register tty driver, " 583 + "ret=%d\n", retval); 584 584 return retval; 585 585 } 586 586 587 - printk(KERN_INFO "gs_module_init: %s %s loaded\n", GS_LONG_NAME, GS_VERSION_STR); 587 + pr_info("gs_module_init: %s %s loaded\n", 588 + GS_LONG_NAME, GS_VERSION_STR); 588 589 return 0; 589 590 } 590 591 ··· 601 598 put_tty_driver(gs_tty_driver); 602 599 usb_gadget_unregister_driver(&gs_gadget_driver); 603 600 604 - printk(KERN_INFO "gs_module_exit: %s %s unloaded\n", GS_LONG_NAME, GS_VERSION_STR); 601 + pr_info("gs_module_exit: %s %s unloaded\n", 602 + GS_LONG_NAME, GS_VERSION_STR); 605 603 } 606 604 607 605 /* TTY Driver */ ··· 625 621 gs_debug("gs_open: (%d,%p,%p)\n", port_num, tty, file); 626 622 627 623 if (port_num < 0 || port_num >= GS_NUM_PORTS) { 628 - printk(KERN_ERR "gs_open: (%d,%p,%p) invalid port number\n", 624 + pr_err("gs_open: (%d,%p,%p) invalid port number\n", 629 625 port_num, tty, file); 630 626 return -ENODEV; 631 627 } ··· 633 629 dev = gs_device; 634 630 635 631 if (dev == NULL) { 636 - printk(KERN_ERR "gs_open: (%d,%p,%p) NULL device pointer\n", 632 + pr_err("gs_open: (%d,%p,%p) NULL device pointer\n", 637 633 port_num, tty, file); 638 634 return -ENODEV; 639 635 } 640 636 641 637 mtx = &gs_open_close_lock[port_num]; 642 638 if (mutex_lock_interruptible(mtx)) { 643 - printk(KERN_ERR 644 - "gs_open: (%d,%p,%p) interrupted waiting for mutex\n", 639 + pr_err("gs_open: (%d,%p,%p) interrupted waiting for mutex\n", 645 640 port_num, tty, file); 646 641 return -ERESTARTSYS; 647 642 } ··· 648 645 spin_lock_irqsave(&dev->dev_lock, flags); 649 646 650 647 if (dev->dev_config == GS_NO_CONFIG_ID) { 651 - printk(KERN_ERR 652 - "gs_open: (%d,%p,%p) device is not connected\n", 648 + pr_err("gs_open: (%d,%p,%p) device is not connected\n", 653 649 port_num, tty, file); 654 650 ret = -ENODEV; 655 651 goto exit_unlock_dev; ··· 657 655 port = dev->dev_port[port_num]; 658 656 659 657 if (port == NULL) { 660 - printk(KERN_ERR "gs_open: (%d,%p,%p) NULL port pointer\n", 658 + pr_err("gs_open: (%d,%p,%p) NULL port pointer\n", 661 659 port_num, tty, file); 662 660 ret = -ENODEV; 663 661 goto exit_unlock_dev; ··· 667 665 spin_unlock(&dev->dev_lock); 668 666 669 667 if (port->port_dev == NULL) { 670 - printk(KERN_ERR "gs_open: (%d,%p,%p) port disconnected (1)\n", 668 + pr_err("gs_open: (%d,%p,%p) port disconnected (1)\n", 671 669 port_num, tty, file); 672 670 ret = -EIO; 673 671 goto exit_unlock_port; ··· 694 692 695 693 /* might have been disconnected while asleep, check */ 696 694 if (port->port_dev == NULL) { 697 - printk(KERN_ERR 698 - "gs_open: (%d,%p,%p) port disconnected (2)\n", 695 + pr_err("gs_open: (%d,%p,%p) port disconnected (2)\n", 699 696 port_num, tty, file); 700 697 port->port_in_use = 0; 701 698 ret = -EIO; ··· 702 701 } 703 702 704 703 if ((port->port_write_buf=buf) == NULL) { 705 - printk(KERN_ERR "gs_open: (%d,%p,%p) cannot allocate port write buffer\n", 704 + pr_err("gs_open: (%d,%p,%p) cannot allocate " 705 + "port write buffer\n", 706 706 port_num, tty, file); 707 707 port->port_in_use = 0; 708 708 ret = -ENOMEM; ··· 716 714 717 715 /* might have been disconnected while asleep, check */ 718 716 if (port->port_dev == NULL) { 719 - printk(KERN_ERR "gs_open: (%d,%p,%p) port disconnected (3)\n", 717 + pr_err("gs_open: (%d,%p,%p) port disconnected (3)\n", 720 718 port_num, tty, file); 721 719 port->port_in_use = 0; 722 720 ret = -EIO; ··· 764 762 struct mutex *mtx; 765 763 766 764 if (port == NULL) { 767 - printk(KERN_ERR "gs_close: NULL port pointer\n"); 765 + pr_err("gs_close: NULL port pointer\n"); 768 766 return; 769 767 } 770 768 ··· 776 774 spin_lock_irq(&port->port_lock); 777 775 778 776 if (port->port_open_count == 0) { 779 - printk(KERN_ERR 780 - "gs_close: (%d,%p,%p) port is already closed\n", 777 + pr_err("gs_close: (%d,%p,%p) port is already closed\n", 781 778 port->port_num, tty, file); 782 779 goto exit; 783 780 } ··· 838 837 int ret; 839 838 840 839 if (port == NULL) { 841 - printk(KERN_ERR "gs_write: NULL port pointer\n"); 840 + pr_err("gs_write: NULL port pointer\n"); 842 841 return -EIO; 843 842 } 844 843 ··· 851 850 spin_lock_irqsave(&port->port_lock, flags); 852 851 853 852 if (port->port_dev == NULL) { 854 - printk(KERN_ERR "gs_write: (%d,%p) port is not connected\n", 853 + pr_err("gs_write: (%d,%p) port is not connected\n", 855 854 port->port_num, tty); 856 855 ret = -EIO; 857 856 goto exit; 858 857 } 859 858 860 859 if (port->port_open_count == 0) { 861 - printk(KERN_ERR "gs_write: (%d,%p) port is closed\n", 860 + pr_err("gs_write: (%d,%p) port is closed\n", 862 861 port->port_num, tty); 863 862 ret = -EBADF; 864 863 goto exit; ··· 889 888 struct gs_port *port = tty->driver_data; 890 889 891 890 if (port == NULL) { 892 - printk(KERN_ERR "gs_put_char: NULL port pointer\n"); 891 + pr_err("gs_put_char: NULL port pointer\n"); 893 892 return; 894 893 } 895 894 ··· 899 898 spin_lock_irqsave(&port->port_lock, flags); 900 899 901 900 if (port->port_dev == NULL) { 902 - printk(KERN_ERR "gs_put_char: (%d,%p) port is not connected\n", 901 + pr_err("gs_put_char: (%d,%p) port is not connected\n", 903 902 port->port_num, tty); 904 903 goto exit; 905 904 } 906 905 907 906 if (port->port_open_count == 0) { 908 - printk(KERN_ERR "gs_put_char: (%d,%p) port is closed\n", 907 + pr_err("gs_put_char: (%d,%p) port is closed\n", 909 908 port->port_num, tty); 910 909 goto exit; 911 910 } ··· 925 924 struct gs_port *port = tty->driver_data; 926 925 927 926 if (port == NULL) { 928 - printk(KERN_ERR "gs_flush_chars: NULL port pointer\n"); 927 + pr_err("gs_flush_chars: NULL port pointer\n"); 929 928 return; 930 929 } 931 930 ··· 934 933 spin_lock_irqsave(&port->port_lock, flags); 935 934 936 935 if (port->port_dev == NULL) { 937 - printk(KERN_ERR 938 - "gs_flush_chars: (%d,%p) port is not connected\n", 936 + pr_err("gs_flush_chars: (%d,%p) port is not connected\n", 939 937 port->port_num, tty); 940 938 goto exit; 941 939 } 942 940 943 941 if (port->port_open_count == 0) { 944 - printk(KERN_ERR "gs_flush_chars: (%d,%p) port is closed\n", 942 + pr_err("gs_flush_chars: (%d,%p) port is closed\n", 945 943 port->port_num, tty); 946 944 goto exit; 947 945 } ··· 1038 1038 struct gs_port *port = tty->driver_data; 1039 1039 1040 1040 if (port == NULL) { 1041 - printk(KERN_ERR "gs_ioctl: NULL port pointer\n"); 1041 + pr_err("gs_ioctl: NULL port pointer\n"); 1042 1042 return -EIO; 1043 1043 } 1044 1044 ··· 1076 1076 struct gs_req_entry *req_entry; 1077 1077 1078 1078 if (dev == NULL) { 1079 - printk(KERN_ERR "gs_send: NULL device pointer\n"); 1079 + pr_err("gs_send: NULL device pointer\n"); 1080 1080 return -ENODEV; 1081 1081 } 1082 1082 ··· 1103 1103 req->length = len; 1104 1104 spin_unlock_irqrestore(&dev->dev_lock, flags); 1105 1105 if ((ret=usb_ep_queue(ep, req, GFP_ATOMIC))) { 1106 - printk(KERN_ERR 1106 + pr_err( 1107 1107 "gs_send: cannot queue read request, ret=%d\n", 1108 1108 ret); 1109 1109 spin_lock_irqsave(&dev->dev_lock, flags); ··· 1144 1144 port = dev->dev_port[0]; 1145 1145 1146 1146 if (port == NULL) { 1147 - printk(KERN_ERR 1148 - "gs_send_packet: port=%d, NULL port pointer\n", 1149 - 0); 1147 + pr_err("gs_send_packet: port=%d, NULL port pointer\n", 0); 1150 1148 return -EIO; 1151 1149 } 1152 1150 ··· 1191 1193 port = dev->dev_port[0]; 1192 1194 1193 1195 if (port == NULL) { 1194 - printk(KERN_ERR "gs_recv_packet: port=%d, NULL port pointer\n", 1196 + pr_err("gs_recv_packet: port=%d, NULL port pointer\n", 1195 1197 port->port_num); 1196 1198 return -EIO; 1197 1199 } ··· 1199 1201 spin_lock(&port->port_lock); 1200 1202 1201 1203 if (port->port_open_count == 0) { 1202 - printk(KERN_ERR "gs_recv_packet: port=%d, port is closed\n", 1204 + pr_err("gs_recv_packet: port=%d, port is closed\n", 1203 1205 port->port_num); 1204 1206 ret = -EIO; 1205 1207 goto exit; ··· 1209 1211 tty = port->port_tty; 1210 1212 1211 1213 if (tty == NULL) { 1212 - printk(KERN_ERR "gs_recv_packet: port=%d, NULL tty pointer\n", 1214 + pr_err("gs_recv_packet: port=%d, NULL tty pointer\n", 1213 1215 port->port_num); 1214 1216 ret = -EIO; 1215 1217 goto exit; 1216 1218 } 1217 1219 1218 1220 if (port->port_tty->magic != TTY_MAGIC) { 1219 - printk(KERN_ERR "gs_recv_packet: port=%d, bad tty magic\n", 1221 + pr_err("gs_recv_packet: port=%d, bad tty magic\n", 1220 1222 port->port_num); 1221 1223 ret = -EIO; 1222 1224 goto exit; ··· 1243 1245 struct gs_dev *dev = ep->driver_data; 1244 1246 1245 1247 if (dev == NULL) { 1246 - printk(KERN_ERR "gs_read_complete: NULL device pointer\n"); 1248 + pr_err("gs_read_complete: NULL device pointer\n"); 1247 1249 return; 1248 1250 } 1249 1251 ··· 1254 1256 requeue: 1255 1257 req->length = ep->maxpacket; 1256 1258 if ((ret=usb_ep_queue(ep, req, GFP_ATOMIC))) { 1257 - printk(KERN_ERR 1259 + pr_err( 1258 1260 "gs_read_complete: cannot queue read request, ret=%d\n", 1259 1261 ret); 1260 1262 } ··· 1268 1270 1269 1271 default: 1270 1272 /* unexpected */ 1271 - printk(KERN_ERR 1273 + pr_err( 1272 1274 "gs_read_complete: unexpected status error, status=%d\n", 1273 1275 req->status); 1274 1276 goto requeue; ··· 1285 1287 struct gs_req_entry *gs_req = req->context; 1286 1288 1287 1289 if (dev == NULL) { 1288 - printk(KERN_ERR "gs_write_complete: NULL device pointer\n"); 1290 + pr_err("gs_write_complete: NULL device pointer\n"); 1289 1291 return; 1290 1292 } 1291 1293 ··· 1294 1296 /* normal completion */ 1295 1297 requeue: 1296 1298 if (gs_req == NULL) { 1297 - printk(KERN_ERR 1298 - "gs_write_complete: NULL request pointer\n"); 1299 + pr_err("gs_write_complete: NULL request pointer\n"); 1299 1300 return; 1300 1301 } 1301 1302 ··· 1313 1316 break; 1314 1317 1315 1318 default: 1316 - printk(KERN_ERR 1319 + pr_err( 1317 1320 "gs_write_complete: unexpected status error, status=%d\n", 1318 1321 req->status); 1319 1322 goto requeue; ··· 1348 1351 gs_device_desc.bcdDevice = 1349 1352 cpu_to_le16(GS_VERSION_NUM | gcnum); 1350 1353 else { 1351 - printk(KERN_WARNING "gs_bind: controller '%s' not recognized\n", 1354 + pr_warning("gs_bind: controller '%s' not recognized\n", 1352 1355 gadget->name); 1353 1356 /* unrecognized, but safe unless bulk is REALLY quirky */ 1354 1357 gs_device_desc.bcdDevice = ··· 1372 1375 if (use_acm) { 1373 1376 ep = usb_ep_autoconfig(gadget, &gs_fullspeed_notify_desc); 1374 1377 if (!ep) { 1375 - printk(KERN_ERR "gs_bind: cannot run ACM on %s\n", gadget->name); 1378 + pr_err("gs_bind: cannot run ACM on %s\n", gadget->name); 1376 1379 goto autoconf_fail; 1377 1380 } 1378 1381 gs_device_desc.idProduct = __constant_cpu_to_le16( ··· 1422 1425 set_gadget_data(gadget, dev); 1423 1426 1424 1427 if ((ret=gs_alloc_ports(dev, GFP_KERNEL)) != 0) { 1425 - printk(KERN_ERR "gs_bind: cannot allocate ports\n"); 1428 + pr_err("gs_bind: cannot allocate ports\n"); 1426 1429 gs_unbind(gadget); 1427 1430 return ret; 1428 1431 } ··· 1438 1441 1439 1442 gadget->ep0->driver_data = dev; 1440 1443 1441 - printk(KERN_INFO "gs_bind: %s %s bound\n", 1444 + pr_info("gs_bind: %s %s bound\n", 1442 1445 GS_LONG_NAME, GS_VERSION_STR); 1443 1446 1444 1447 return 0; 1445 1448 1446 1449 autoconf_fail: 1447 - printk(KERN_ERR "gs_bind: cannot autoconfigure on %s\n", gadget->name); 1450 + pr_err("gs_bind: cannot autoconfigure on %s\n", gadget->name); 1448 1451 return -ENODEV; 1449 1452 } 1450 1453 ··· 1477 1480 set_gadget_data(gadget, NULL); 1478 1481 } 1479 1482 1480 - printk(KERN_INFO "gs_unbind: %s %s unbound\n", GS_LONG_NAME, 1483 + pr_info("gs_unbind: %s %s unbound\n", GS_LONG_NAME, 1481 1484 GS_VERSION_STR); 1482 1485 } 1483 1486 ··· 1510 1513 break; 1511 1514 1512 1515 default: 1513 - printk(KERN_ERR "gs_setup: unknown request, type=%02x, request=%02x, value=%04x, index=%04x, length=%d\n", 1516 + pr_err("gs_setup: unknown request, type=%02x, request=%02x, " 1517 + "value=%04x, index=%04x, length=%d\n", 1514 1518 ctrl->bRequestType, ctrl->bRequest, 1515 1519 wValue, wIndex, wLength); 1516 1520 break; ··· 1524 1526 && (ret % gadget->ep0->maxpacket) == 0; 1525 1527 ret = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC); 1526 1528 if (ret < 0) { 1527 - printk(KERN_ERR "gs_setup: cannot queue response, ret=%d\n", 1529 + pr_err("gs_setup: cannot queue response, ret=%d\n", 1528 1530 ret); 1529 1531 req->status = 0; 1530 1532 gs_setup_complete(gadget->ep0, req); ··· 1654 1656 break; 1655 1657 1656 1658 default: 1657 - printk(KERN_ERR "gs_setup: unknown standard request, type=%02x, request=%02x, value=%04x, index=%04x, length=%d\n", 1659 + pr_err("gs_setup: unknown standard request, type=%02x, " 1660 + "request=%02x, value=%04x, index=%04x, length=%d\n", 1658 1661 ctrl->bRequestType, ctrl->bRequest, 1659 1662 wValue, wIndex, wLength); 1660 1663 break; ··· 1681 1682 * handler copy that data to port->port_line_coding (iff 1682 1683 * it's valid) and maybe pass it on. Until then, fail. 1683 1684 */ 1684 - printk(KERN_WARNING "gs_setup: set_line_coding " 1685 + pr_warning("gs_setup: set_line_coding " 1685 1686 "unuspported\n"); 1686 1687 break; 1687 1688 ··· 1701 1702 * handler use that to set the state (iff it's valid) and 1702 1703 * maybe pass it on. Until then, fail. 1703 1704 */ 1704 - printk(KERN_WARNING "gs_setup: set_control_line_state " 1705 + pr_warning("gs_setup: set_control_line_state " 1705 1706 "unuspported\n"); 1706 1707 break; 1707 1708 1708 1709 default: 1709 - printk(KERN_ERR "gs_setup: unknown class request, " 1710 + pr_err("gs_setup: unknown class request, " 1710 1711 "type=%02x, request=%02x, value=%04x, " 1711 1712 "index=%04x, length=%d\n", 1712 1713 ctrl->bRequestType, ctrl->bRequest, ··· 1723 1724 static void gs_setup_complete(struct usb_ep *ep, struct usb_request *req) 1724 1725 { 1725 1726 if (req->status || req->actual != req->length) { 1726 - printk(KERN_ERR "gs_setup_complete: status error, status=%d, actual=%d, length=%d\n", 1727 + pr_err("gs_setup_complete: status error, status=%d, " 1728 + "actual=%d, length=%d\n", 1727 1729 req->status, req->actual, req->length); 1728 1730 } 1729 1731 } ··· 1751 1751 1752 1752 /* re-allocate ports for the next connection */ 1753 1753 if (gs_alloc_ports(dev, GFP_ATOMIC) != 0) 1754 - printk(KERN_ERR "gs_disconnect: cannot re-allocate ports\n"); 1754 + pr_err("gs_disconnect: cannot re-allocate ports\n"); 1755 1755 1756 1756 spin_unlock_irqrestore(&dev->dev_lock, flags); 1757 1757 1758 - printk(KERN_INFO "gs_disconnect: %s disconnected\n", GS_LONG_NAME); 1758 + pr_info("gs_disconnect: %s disconnected\n", GS_LONG_NAME); 1759 1759 } 1760 1760 1761 1761 /* ··· 1778 1778 struct gs_req_entry *req_entry; 1779 1779 1780 1780 if (dev == NULL) { 1781 - printk(KERN_ERR "gs_set_config: NULL device pointer\n"); 1781 + pr_err("gs_set_config: NULL device pointer\n"); 1782 1782 return 0; 1783 1783 } 1784 1784 ··· 1823 1823 dev->dev_notify_ep = ep; 1824 1824 dev->dev_notify_ep_desc = ep_desc; 1825 1825 } else { 1826 - printk(KERN_ERR "gs_set_config: cannot enable notify endpoint %s, ret=%d\n", 1826 + pr_err("gs_set_config: cannot enable NOTIFY " 1827 + "endpoint %s, ret=%d\n", 1827 1828 ep->name, ret); 1828 1829 goto exit_reset_config; 1829 1830 } ··· 1840 1839 dev->dev_in_ep = ep; 1841 1840 dev->dev_in_ep_desc = ep_desc; 1842 1841 } else { 1843 - printk(KERN_ERR "gs_set_config: cannot enable in endpoint %s, ret=%d\n", 1842 + pr_err("gs_set_config: cannot enable IN " 1843 + "endpoint %s, ret=%d\n", 1844 1844 ep->name, ret); 1845 1845 goto exit_reset_config; 1846 1846 } ··· 1857 1855 dev->dev_out_ep = ep; 1858 1856 dev->dev_out_ep_desc = ep_desc; 1859 1857 } else { 1860 - printk(KERN_ERR "gs_set_config: cannot enable out endpoint %s, ret=%d\n", 1858 + pr_err("gs_set_config: cannot enable OUT " 1859 + "endpoint %s, ret=%d\n", 1861 1860 ep->name, ret); 1862 1861 goto exit_reset_config; 1863 1862 } ··· 1868 1865 1869 1866 if (dev->dev_in_ep == NULL || dev->dev_out_ep == NULL 1870 1867 || (config != GS_BULK_CONFIG_ID && dev->dev_notify_ep == NULL)) { 1871 - printk(KERN_ERR "gs_set_config: cannot find endpoints\n"); 1868 + pr_err("gs_set_config: cannot find endpoints\n"); 1872 1869 ret = -ENODEV; 1873 1870 goto exit_reset_config; 1874 1871 } ··· 1879 1876 if ((req=gs_alloc_req(ep, ep->maxpacket, GFP_ATOMIC))) { 1880 1877 req->complete = gs_read_complete; 1881 1878 if ((ret=usb_ep_queue(ep, req, GFP_ATOMIC))) { 1882 - printk(KERN_ERR "gs_set_config: cannot queue read request, ret=%d\n", 1883 - ret); 1879 + pr_err("gs_set_config: cannot queue read " 1880 + "request, ret=%d\n", ret); 1884 1881 } 1885 1882 } else { 1886 - printk(KERN_ERR "gs_set_config: cannot allocate read requests\n"); 1883 + pr_err("gs_set_config: cannot allocate " 1884 + "read requests\n"); 1887 1885 ret = -ENOMEM; 1888 1886 goto exit_reset_config; 1889 1887 } ··· 1897 1893 req_entry->re_req->complete = gs_write_complete; 1898 1894 list_add(&req_entry->re_entry, &dev->dev_req_list); 1899 1895 } else { 1900 - printk(KERN_ERR "gs_set_config: cannot allocate write requests\n"); 1896 + pr_err("gs_set_config: cannot allocate " 1897 + "write requests\n"); 1901 1898 ret = -ENOMEM; 1902 1899 goto exit_reset_config; 1903 1900 } 1904 1901 } 1905 1902 1906 - printk(KERN_INFO "gs_set_config: %s configured, %s speed %s config\n", 1903 + pr_info("gs_set_config: %s configured, %s speed %s config\n", 1907 1904 GS_LONG_NAME, 1908 1905 gadget->speed == USB_SPEED_HIGH ? "high" : "full", 1909 1906 config == GS_BULK_CONFIG_ID ? "BULK" : "CDC-ACM"); ··· 1931 1926 struct gs_req_entry *req_entry; 1932 1927 1933 1928 if (dev == NULL) { 1934 - printk(KERN_ERR "gs_reset_config: NULL device pointer\n"); 1929 + pr_err("gs_reset_config: NULL device pointer\n"); 1935 1930 return; 1936 1931 } 1937 1932
+2 -2
drivers/usb/gadget/zero.c
··· 1115 1115 ep = usb_ep_autoconfig (gadget, &fs_source_desc); 1116 1116 if (!ep) { 1117 1117 autoconf_fail: 1118 - printk (KERN_ERR "%s: can't autoconfigure on %s\n", 1118 + pr_err("%s: can't autoconfigure on %s\n", 1119 1119 shortname, gadget->name); 1120 1120 return -ENODEV; 1121 1121 } ··· 1139 1139 * things like configuration and altsetting numbering 1140 1140 * can need hardware-specific attention though. 1141 1141 */ 1142 - printk (KERN_WARNING "%s: controller '%s' not recognized\n", 1142 + pr_warning("%s: controller '%s' not recognized\n", 1143 1143 shortname, gadget->name); 1144 1144 device_desc.bcdDevice = __constant_cpu_to_le16 (0x9999); 1145 1145 }
+11 -11
drivers/usb/host/Kconfig
··· 29 29 To compile this driver as a module, choose M here: the 30 30 module will be called ehci-hcd. 31 31 32 - config USB_EHCI_SPLIT_ISO 33 - bool "Full speed ISO transactions (EXPERIMENTAL)" 34 - depends on USB_EHCI_HCD && EXPERIMENTAL 35 - default n 36 - ---help--- 37 - This code is new and hasn't been used with many different 38 - EHCI or USB 2.0 transaction translator implementations. 39 - It should work for ISO-OUT transfers, like audio. 40 - 41 32 config USB_EHCI_ROOT_HUB_TT 42 33 bool "Root Hub Transaction Translators (EXPERIMENTAL)" 43 34 depends on USB_EHCI_HCD && EXPERIMENTAL ··· 60 69 61 70 config USB_EHCI_BIG_ENDIAN_MMIO 62 71 bool 63 - depends on USB_EHCI_HCD && (PPC_CELLEB || PPC_PS3 || 440EPX) 72 + depends on USB_EHCI_HCD && (PPC_CELLEB || PPC_PS3 || 440EPX || ARCH_IXP4XX) 64 73 default y 65 74 66 75 config USB_EHCI_BIG_ENDIAN_DESC 67 76 bool 68 - depends on USB_EHCI_HCD && 440EPX 77 + depends on USB_EHCI_HCD && (440EPX || ARCH_IXP4XX) 69 78 default y 70 79 71 80 config USB_EHCI_FSL 72 81 bool 82 + depends on USB_EHCI_HCD 73 83 select USB_EHCI_ROOT_HUB_TT 74 84 default y if MPC834x || PPC_MPC831x 75 85 ---help--- 76 86 Variation of ARC USB block used in some Freescale chips. 87 + 88 + config USB_EHCI_HCD_PPC_OF 89 + bool "EHCI support for PPC USB controller on OF platform bus" 90 + depends on USB_EHCI_HCD && PPC_OF 91 + default y 92 + ---help--- 93 + Enables support for the USB controller present on the PowerPC 94 + OpenFirmware platform bus. 77 95 78 96 config USB_ISP116X_HCD 79 97 tristate "ISP116X HCD support"
+1
drivers/usb/host/ehci-au1xxx.c
··· 222 222 .hub_control = ehci_hub_control, 223 223 .bus_suspend = ehci_bus_suspend, 224 224 .bus_resume = ehci_bus_resume, 225 + .relinquish_port = ehci_relinquish_port, 225 226 }; 226 227 227 228 /*-------------------------------------------------------------------------*/
+187 -42
drivers/usb/host/ehci-dbg.c
··· 323 323 324 324 #else 325 325 326 - /* troubleshooting help: expose state in sysfs */ 326 + /* troubleshooting help: expose state in debugfs */ 327 + 328 + static int debug_async_open(struct inode *, struct file *); 329 + static int debug_periodic_open(struct inode *, struct file *); 330 + static int debug_registers_open(struct inode *, struct file *); 331 + static int debug_async_open(struct inode *, struct file *); 332 + static ssize_t debug_output(struct file*, char __user*, size_t, loff_t*); 333 + static int debug_close(struct inode *, struct file *); 334 + 335 + static const struct file_operations debug_async_fops = { 336 + .owner = THIS_MODULE, 337 + .open = debug_async_open, 338 + .read = debug_output, 339 + .release = debug_close, 340 + }; 341 + static const struct file_operations debug_periodic_fops = { 342 + .owner = THIS_MODULE, 343 + .open = debug_periodic_open, 344 + .read = debug_output, 345 + .release = debug_close, 346 + }; 347 + static const struct file_operations debug_registers_fops = { 348 + .owner = THIS_MODULE, 349 + .open = debug_registers_open, 350 + .read = debug_output, 351 + .release = debug_close, 352 + }; 353 + 354 + static struct dentry *ehci_debug_root; 355 + 356 + struct debug_buffer { 357 + ssize_t (*fill_func)(struct debug_buffer *); /* fill method */ 358 + struct usb_bus *bus; 359 + struct mutex mutex; /* protect filling of buffer */ 360 + size_t count; /* number of characters filled into buffer */ 361 + char *page; 362 + }; 327 363 328 364 #define speed_char(info1) ({ char tmp; \ 329 365 switch (info1 & (3 << 12)) { \ ··· 477 441 *nextp = next; 478 442 } 479 443 480 - static ssize_t 481 - show_async (struct class_device *class_dev, char *buf) 444 + static ssize_t fill_async_buffer(struct debug_buffer *buf) 482 445 { 483 - struct usb_bus *bus; 484 446 struct usb_hcd *hcd; 485 447 struct ehci_hcd *ehci; 486 448 unsigned long flags; ··· 486 452 char *next; 487 453 struct ehci_qh *qh; 488 454 489 - *buf = 0; 490 - 491 - bus = class_get_devdata(class_dev); 492 - hcd = bus_to_hcd(bus); 455 + hcd = bus_to_hcd(buf->bus); 493 456 ehci = hcd_to_ehci (hcd); 494 - next = buf; 457 + next = buf->page; 495 458 size = PAGE_SIZE; 459 + 460 + *next = 0; 496 461 497 462 /* dumps a snapshot of the async schedule. 498 463 * usually empty except for long-term bulk reads, or head. ··· 510 477 } 511 478 spin_unlock_irqrestore (&ehci->lock, flags); 512 479 513 - return strlen (buf); 480 + return strlen(buf->page); 514 481 } 515 - static CLASS_DEVICE_ATTR (async, S_IRUGO, show_async, NULL); 516 482 517 483 #define DBG_SCHED_LIMIT 64 518 - 519 - static ssize_t 520 - show_periodic (struct class_device *class_dev, char *buf) 484 + static ssize_t fill_periodic_buffer(struct debug_buffer *buf) 521 485 { 522 - struct usb_bus *bus; 523 486 struct usb_hcd *hcd; 524 487 struct ehci_hcd *ehci; 525 488 unsigned long flags; ··· 529 500 return 0; 530 501 seen_count = 0; 531 502 532 - bus = class_get_devdata(class_dev); 533 - hcd = bus_to_hcd(bus); 503 + hcd = bus_to_hcd(buf->bus); 534 504 ehci = hcd_to_ehci (hcd); 535 - next = buf; 505 + next = buf->page; 536 506 size = PAGE_SIZE; 537 507 538 508 temp = scnprintf (next, size, "size = %d\n", ehci->periodic_size); ··· 651 623 652 624 return PAGE_SIZE - size; 653 625 } 654 - static CLASS_DEVICE_ATTR (periodic, S_IRUGO, show_periodic, NULL); 655 - 656 626 #undef DBG_SCHED_LIMIT 657 627 658 - static ssize_t 659 - show_registers (struct class_device *class_dev, char *buf) 628 + static ssize_t fill_registers_buffer(struct debug_buffer *buf) 660 629 { 661 - struct usb_bus *bus; 662 630 struct usb_hcd *hcd; 663 631 struct ehci_hcd *ehci; 664 632 unsigned long flags; ··· 663 639 static char fmt [] = "%*s\n"; 664 640 static char label [] = ""; 665 641 666 - bus = class_get_devdata(class_dev); 667 - hcd = bus_to_hcd(bus); 642 + hcd = bus_to_hcd(buf->bus); 668 643 ehci = hcd_to_ehci (hcd); 669 - next = buf; 644 + next = buf->page; 670 645 size = PAGE_SIZE; 671 646 672 647 spin_lock_irqsave (&ehci->lock, flags); 673 648 674 - if (bus->controller->power.power_state.event) { 649 + if (buf->bus->controller->power.power_state.event) { 675 650 size = scnprintf (next, size, 676 651 "bus %s, device %s (driver " DRIVER_VERSION ")\n" 677 652 "%s\n" ··· 786 763 } 787 764 788 765 if (ehci->reclaim) { 789 - temp = scnprintf (next, size, "reclaim qh %p%s\n", 790 - ehci->reclaim, 791 - ehci->reclaim_ready ? " ready" : ""); 766 + temp = scnprintf(next, size, "reclaim qh %p\n", ehci->reclaim); 792 767 size -= temp; 793 768 next += temp; 794 769 } ··· 810 789 811 790 return PAGE_SIZE - size; 812 791 } 813 - static CLASS_DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL); 792 + 793 + static struct debug_buffer *alloc_buffer(struct usb_bus *bus, 794 + ssize_t (*fill_func)(struct debug_buffer *)) 795 + { 796 + struct debug_buffer *buf; 797 + 798 + buf = kzalloc(sizeof(struct debug_buffer), GFP_KERNEL); 799 + 800 + if (buf) { 801 + buf->bus = bus; 802 + buf->fill_func = fill_func; 803 + mutex_init(&buf->mutex); 804 + } 805 + 806 + return buf; 807 + } 808 + 809 + static int fill_buffer(struct debug_buffer *buf) 810 + { 811 + int ret = 0; 812 + 813 + if (!buf->page) 814 + buf->page = (char *)get_zeroed_page(GFP_KERNEL); 815 + 816 + if (!buf->page) { 817 + ret = -ENOMEM; 818 + goto out; 819 + } 820 + 821 + ret = buf->fill_func(buf); 822 + 823 + if (ret >= 0) { 824 + buf->count = ret; 825 + ret = 0; 826 + } 827 + 828 + out: 829 + return ret; 830 + } 831 + 832 + static ssize_t debug_output(struct file *file, char __user *user_buf, 833 + size_t len, loff_t *offset) 834 + { 835 + struct debug_buffer *buf = file->private_data; 836 + int ret = 0; 837 + 838 + mutex_lock(&buf->mutex); 839 + if (buf->count == 0) { 840 + ret = fill_buffer(buf); 841 + if (ret != 0) { 842 + mutex_unlock(&buf->mutex); 843 + goto out; 844 + } 845 + } 846 + mutex_unlock(&buf->mutex); 847 + 848 + ret = simple_read_from_buffer(user_buf, len, offset, 849 + buf->page, buf->count); 850 + 851 + out: 852 + return ret; 853 + 854 + } 855 + 856 + static int debug_close(struct inode *inode, struct file *file) 857 + { 858 + struct debug_buffer *buf = file->private_data; 859 + 860 + if (buf) { 861 + if (buf->page) 862 + free_page((unsigned long)buf->page); 863 + kfree(buf); 864 + } 865 + 866 + return 0; 867 + } 868 + static int debug_async_open(struct inode *inode, struct file *file) 869 + { 870 + file->private_data = alloc_buffer(inode->i_private, fill_async_buffer); 871 + 872 + return file->private_data ? 0 : -ENOMEM; 873 + } 874 + 875 + static int debug_periodic_open(struct inode *inode, struct file *file) 876 + { 877 + file->private_data = alloc_buffer(inode->i_private, 878 + fill_periodic_buffer); 879 + 880 + return file->private_data ? 0 : -ENOMEM; 881 + } 882 + 883 + static int debug_registers_open(struct inode *inode, struct file *file) 884 + { 885 + file->private_data = alloc_buffer(inode->i_private, 886 + fill_registers_buffer); 887 + 888 + return file->private_data ? 0 : -ENOMEM; 889 + } 814 890 815 891 static inline void create_debug_files (struct ehci_hcd *ehci) 816 892 { 817 - struct class_device *cldev = ehci_to_hcd(ehci)->self.class_dev; 818 - int retval; 893 + struct usb_bus *bus = &ehci_to_hcd(ehci)->self; 819 894 820 - retval = class_device_create_file(cldev, &class_device_attr_async); 821 - retval = class_device_create_file(cldev, &class_device_attr_periodic); 822 - retval = class_device_create_file(cldev, &class_device_attr_registers); 895 + ehci->debug_dir = debugfs_create_dir(bus->bus_name, ehci_debug_root); 896 + if (!ehci->debug_dir) 897 + goto dir_error; 898 + 899 + ehci->debug_async = debugfs_create_file("async", S_IRUGO, 900 + ehci->debug_dir, bus, 901 + &debug_async_fops); 902 + if (!ehci->debug_async) 903 + goto async_error; 904 + 905 + ehci->debug_periodic = debugfs_create_file("periodic", S_IRUGO, 906 + ehci->debug_dir, bus, 907 + &debug_periodic_fops); 908 + if (!ehci->debug_periodic) 909 + goto periodic_error; 910 + 911 + ehci->debug_registers = debugfs_create_file("registers", S_IRUGO, 912 + ehci->debug_dir, bus, 913 + &debug_registers_fops); 914 + if (!ehci->debug_registers) 915 + goto registers_error; 916 + return; 917 + 918 + registers_error: 919 + debugfs_remove(ehci->debug_periodic); 920 + periodic_error: 921 + debugfs_remove(ehci->debug_async); 922 + async_error: 923 + debugfs_remove(ehci->debug_dir); 924 + dir_error: 925 + ehci->debug_periodic = NULL; 926 + ehci->debug_async = NULL; 927 + ehci->debug_dir = NULL; 823 928 } 824 929 825 930 static inline void remove_debug_files (struct ehci_hcd *ehci) 826 931 { 827 - struct class_device *cldev = ehci_to_hcd(ehci)->self.class_dev; 828 - 829 - class_device_remove_file(cldev, &class_device_attr_async); 830 - class_device_remove_file(cldev, &class_device_attr_periodic); 831 - class_device_remove_file(cldev, &class_device_attr_registers); 932 + debugfs_remove(ehci->debug_registers); 933 + debugfs_remove(ehci->debug_periodic); 934 + debugfs_remove(ehci->debug_async); 935 + debugfs_remove(ehci->debug_dir); 832 936 } 833 937 834 938 #endif /* STUB_DEBUG_FILES */ 835 -
+2 -1
drivers/usb/host/ehci-fsl.c
··· 25 25 26 26 #include "ehci-fsl.h" 27 27 28 - /* FIXME: Power Managment is un-ported so temporarily disable it */ 28 + /* FIXME: Power Management is un-ported so temporarily disable it */ 29 29 #undef CONFIG_PM 30 30 31 31 /* PCI-based HCs are common, but plenty of non-PCI HCs are used too */ ··· 323 323 .hub_control = ehci_hub_control, 324 324 .bus_suspend = ehci_bus_suspend, 325 325 .bus_resume = ehci_bus_resume, 326 + .relinquish_port = ehci_relinquish_port, 326 327 }; 327 328 328 329 static int ehci_fsl_drv_probe(struct platform_device *pdev)
+120 -43
drivers/usb/host/ehci-hcd.c
··· 33 33 #include <linux/usb.h> 34 34 #include <linux/moduleparam.h> 35 35 #include <linux/dma-mapping.h> 36 + #include <linux/debugfs.h> 36 37 37 38 #include "../core/hcd.h" 38 39 ··· 110 109 #define EHCI_TUNE_MULT_TT 1 111 110 #define EHCI_TUNE_FLS 2 /* (small) 256 frame schedule */ 112 111 113 - #define EHCI_IAA_JIFFIES (HZ/100) /* arbitrary; ~10 msec */ 112 + #define EHCI_IAA_MSECS 10 /* arbitrary */ 114 113 #define EHCI_IO_JIFFIES (HZ/10) /* io watchdog > irq_thresh */ 115 114 #define EHCI_ASYNC_JIFFIES (HZ/20) /* async idle timeout */ 116 115 #define EHCI_SHRINK_JIFFIES (HZ/200) /* async qh unlink delay */ ··· 267 266 268 267 /*-------------------------------------------------------------------------*/ 269 268 269 + static void end_unlink_async(struct ehci_hcd *ehci); 270 270 static void ehci_work(struct ehci_hcd *ehci); 271 271 272 272 #include "ehci-hub.c" ··· 277 275 278 276 /*-------------------------------------------------------------------------*/ 279 277 280 - static void ehci_watchdog (unsigned long param) 278 + static void ehci_iaa_watchdog(unsigned long param) 281 279 { 282 280 struct ehci_hcd *ehci = (struct ehci_hcd *) param; 283 281 unsigned long flags; 282 + u32 status, cmd; 284 283 285 284 spin_lock_irqsave (&ehci->lock, flags); 285 + WARN_ON(!ehci->reclaim); 286 286 287 - /* lost IAA irqs wedge things badly; seen with a vt8235 */ 287 + status = ehci_readl(ehci, &ehci->regs->status); 288 + cmd = ehci_readl(ehci, &ehci->regs->command); 289 + ehci_dbg(ehci, "IAA watchdog: status %x cmd %x\n", status, cmd); 290 + 291 + /* lost IAA irqs wedge things badly; seen first with a vt8235 */ 288 292 if (ehci->reclaim) { 289 - u32 status = ehci_readl(ehci, &ehci->regs->status); 290 293 if (status & STS_IAA) { 291 294 ehci_vdbg (ehci, "lost IAA\n"); 292 295 COUNT (ehci->stats.lost_iaa); 293 296 ehci_writel(ehci, STS_IAA, &ehci->regs->status); 294 - ehci->reclaim_ready = 1; 295 297 } 298 + ehci_writel(ehci, cmd & ~CMD_IAAD, &ehci->regs->command); 299 + end_unlink_async(ehci); 296 300 } 297 301 298 - /* stop async processing after it's idled a bit */ 302 + spin_unlock_irqrestore(&ehci->lock, flags); 303 + } 304 + 305 + static void ehci_watchdog(unsigned long param) 306 + { 307 + struct ehci_hcd *ehci = (struct ehci_hcd *) param; 308 + unsigned long flags; 309 + 310 + spin_lock_irqsave(&ehci->lock, flags); 311 + 312 + /* stop async processing after it's idled a bit */ 299 313 if (test_bit (TIMER_ASYNC_OFF, &ehci->actions)) 300 314 start_unlink_async (ehci, ehci->async); 301 315 ··· 381 363 static void ehci_work (struct ehci_hcd *ehci) 382 364 { 383 365 timer_action_done (ehci, TIMER_IO_WATCHDOG); 384 - if (ehci->reclaim_ready) 385 - end_unlink_async (ehci); 386 366 387 367 /* another CPU may drop ehci->lock during a schedule scan while 388 368 * it reports urb completions. this flag guards against bogus ··· 415 399 416 400 /* no more interrupts ... */ 417 401 del_timer_sync (&ehci->watchdog); 402 + del_timer_sync(&ehci->iaa_watchdog); 418 403 419 404 spin_lock_irq(&ehci->lock); 420 405 if (HC_IS_RUNNING (hcd->state)) ··· 464 447 ehci->watchdog.function = ehci_watchdog; 465 448 ehci->watchdog.data = (unsigned long) ehci; 466 449 450 + init_timer(&ehci->iaa_watchdog); 451 + ehci->iaa_watchdog.function = ehci_iaa_watchdog; 452 + ehci->iaa_watchdog.data = (unsigned long) ehci; 453 + 467 454 /* 468 455 * hw default: 1K periodic list heads, one per frame. 469 456 * periodic_size can shrink by USBCMD update if hcc_params allows. ··· 484 463 ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params); 485 464 486 465 ehci->reclaim = NULL; 487 - ehci->reclaim_ready = 0; 488 466 ehci->next_uframe = -1; 489 467 490 468 /* ··· 674 654 /* complete the unlinking of some qh [4.15.2.3] */ 675 655 if (status & STS_IAA) { 676 656 COUNT (ehci->stats.reclaim); 677 - ehci->reclaim_ready = 1; 678 - bh = 1; 657 + end_unlink_async(ehci); 679 658 } 680 659 681 660 /* remote wakeup [4.3.1] */ ··· 780 761 781 762 static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh) 782 763 { 783 - /* if we need to use IAA and it's busy, defer */ 784 - if (qh->qh_state == QH_STATE_LINKED 785 - && ehci->reclaim 786 - && HC_IS_RUNNING (ehci_to_hcd(ehci)->state)) { 764 + /* failfast */ 765 + if (!HC_IS_RUNNING(ehci_to_hcd(ehci)->state)) 766 + end_unlink_async(ehci); 767 + 768 + /* if it's not linked then there's nothing to do */ 769 + if (qh->qh_state != QH_STATE_LINKED) 770 + ; 771 + 772 + /* defer till later if busy */ 773 + else if (ehci->reclaim) { 787 774 struct ehci_qh *last; 788 775 789 776 for (last = ehci->reclaim; ··· 799 774 qh->qh_state = QH_STATE_UNLINK_WAIT; 800 775 last->reclaim = qh; 801 776 802 - /* bypass IAA if the hc can't care */ 803 - } else if (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state) && ehci->reclaim) 804 - end_unlink_async (ehci); 805 - 806 - /* something else might have unlinked the qh by now */ 807 - if (qh->qh_state == QH_STATE_LINKED) 777 + /* start IAA cycle */ 778 + } else 808 779 start_unlink_async (ehci, qh); 809 780 } 810 781 ··· 827 806 qh = (struct ehci_qh *) urb->hcpriv; 828 807 if (!qh) 829 808 break; 830 - unlink_async (ehci, qh); 809 + switch (qh->qh_state) { 810 + case QH_STATE_LINKED: 811 + case QH_STATE_COMPLETING: 812 + unlink_async(ehci, qh); 813 + break; 814 + case QH_STATE_UNLINK: 815 + case QH_STATE_UNLINK_WAIT: 816 + /* already started */ 817 + break; 818 + case QH_STATE_IDLE: 819 + WARN_ON(1); 820 + break; 821 + } 831 822 break; 832 823 833 824 case PIPE_INTERRUPT: ··· 862 829 /* reschedule QH iff another request is queued */ 863 830 if (!list_empty (&qh->qtd_list) 864 831 && HC_IS_RUNNING (hcd->state)) { 865 - int status; 832 + int schedule_status; 866 833 867 - status = qh_schedule (ehci, qh); 834 + schedule_status = qh_schedule (ehci, qh); 868 835 spin_unlock_irqrestore (&ehci->lock, flags); 869 836 870 - if (status != 0) { 837 + if (schedule_status != 0) { 871 838 // shouldn't happen often, but ... 872 839 // FIXME kill those tds' urbs 873 840 err ("can't reschedule qh %p, err %d", 874 - qh, status); 841 + qh, schedule_status); 875 842 } 876 843 return status; 877 844 } ··· 931 898 unlink_async (ehci, qh); 932 899 /* FALL THROUGH */ 933 900 case QH_STATE_UNLINK: /* wait for hw to finish? */ 901 + case QH_STATE_UNLINK_WAIT: 934 902 idle_timeout: 935 903 spin_unlock_irqrestore (&ehci->lock, flags); 936 904 schedule_timeout_uninterruptible(1); ··· 993 959 #define PS3_SYSTEM_BUS_DRIVER ps3_ehci_driver 994 960 #endif 995 961 996 - #ifdef CONFIG_440EPX 962 + #if defined(CONFIG_440EPX) && !defined(CONFIG_PPC_MERGE) 997 963 #include "ehci-ppc-soc.c" 998 964 #define PLATFORM_DRIVER ehci_ppc_soc_driver 965 + #endif 966 + 967 + #ifdef CONFIG_USB_EHCI_HCD_PPC_OF 968 + #include "ehci-ppc-of.c" 969 + #define OF_PLATFORM_DRIVER ehci_hcd_ppc_of_driver 970 + #endif 971 + 972 + #ifdef CONFIG_ARCH_ORION 973 + #include "ehci-orion.c" 974 + #define PLATFORM_DRIVER ehci_orion_driver 975 + #endif 976 + 977 + #ifdef CONFIG_ARCH_IXP4XX 978 + #include "ehci-ixp4xx.c" 979 + #define PLATFORM_DRIVER ixp4xx_ehci_driver 999 980 #endif 1000 981 1001 982 #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ ··· 1027 978 sizeof(struct ehci_qh), sizeof(struct ehci_qtd), 1028 979 sizeof(struct ehci_itd), sizeof(struct ehci_sitd)); 1029 980 981 + #ifdef DEBUG 982 + ehci_debug_root = debugfs_create_dir("ehci", NULL); 983 + if (!ehci_debug_root) 984 + return -ENOENT; 985 + #endif 986 + 1030 987 #ifdef PLATFORM_DRIVER 1031 988 retval = platform_driver_register(&PLATFORM_DRIVER); 1032 989 if (retval < 0) 1033 - return retval; 990 + goto clean0; 1034 991 #endif 1035 992 1036 993 #ifdef PCI_DRIVER 1037 994 retval = pci_register_driver(&PCI_DRIVER); 1038 - if (retval < 0) { 1039 - #ifdef PLATFORM_DRIVER 1040 - platform_driver_unregister(&PLATFORM_DRIVER); 1041 - #endif 1042 - return retval; 1043 - } 995 + if (retval < 0) 996 + goto clean1; 1044 997 #endif 1045 998 1046 999 #ifdef PS3_SYSTEM_BUS_DRIVER 1047 1000 retval = ps3_ehci_driver_register(&PS3_SYSTEM_BUS_DRIVER); 1048 - if (retval < 0) { 1049 - #ifdef PLATFORM_DRIVER 1050 - platform_driver_unregister(&PLATFORM_DRIVER); 1051 - #endif 1052 - #ifdef PCI_DRIVER 1053 - pci_unregister_driver(&PCI_DRIVER); 1054 - #endif 1055 - return retval; 1056 - } 1001 + if (retval < 0) 1002 + goto clean2; 1057 1003 #endif 1058 1004 1005 + #ifdef OF_PLATFORM_DRIVER 1006 + retval = of_register_platform_driver(&OF_PLATFORM_DRIVER); 1007 + if (retval < 0) 1008 + goto clean3; 1009 + #endif 1010 + return retval; 1011 + 1012 + #ifdef OF_PLATFORM_DRIVER 1013 + /* of_unregister_platform_driver(&OF_PLATFORM_DRIVER); */ 1014 + clean3: 1015 + #endif 1016 + #ifdef PS3_SYSTEM_BUS_DRIVER 1017 + ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); 1018 + clean2: 1019 + #endif 1020 + #ifdef PCI_DRIVER 1021 + pci_unregister_driver(&PCI_DRIVER); 1022 + clean1: 1023 + #endif 1024 + #ifdef PLATFORM_DRIVER 1025 + platform_driver_unregister(&PLATFORM_DRIVER); 1026 + clean0: 1027 + #endif 1028 + #ifdef DEBUG 1029 + debugfs_remove(ehci_debug_root); 1030 + ehci_debug_root = NULL; 1031 + #endif 1059 1032 return retval; 1060 1033 } 1061 1034 module_init(ehci_hcd_init); 1062 1035 1063 1036 static void __exit ehci_hcd_cleanup(void) 1064 1037 { 1038 + #ifdef OF_PLATFORM_DRIVER 1039 + of_unregister_platform_driver(&OF_PLATFORM_DRIVER); 1040 + #endif 1065 1041 #ifdef PLATFORM_DRIVER 1066 1042 platform_driver_unregister(&PLATFORM_DRIVER); 1067 1043 #endif ··· 1095 1021 #endif 1096 1022 #ifdef PS3_SYSTEM_BUS_DRIVER 1097 1023 ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); 1024 + #endif 1025 + #ifdef DEBUG 1026 + debugfs_remove(ehci_debug_root); 1098 1027 #endif 1099 1028 } 1100 1029 module_exit(ehci_hcd_cleanup);
+61 -37
drivers/usb/host/ehci-hub.c
··· 123 123 124 124 if (time_before (jiffies, ehci->next_statechange)) 125 125 msleep(5); 126 + del_timer_sync(&ehci->watchdog); 127 + del_timer_sync(&ehci->iaa_watchdog); 126 128 127 129 port = HCS_N_PORTS (ehci->hcs_params); 128 130 spin_lock_irq (&ehci->lock); ··· 136 134 } 137 135 ehci->command = ehci_readl(ehci, &ehci->regs->command); 138 136 if (ehci->reclaim) 139 - ehci->reclaim_ready = 1; 137 + end_unlink_async(ehci); 140 138 ehci_work(ehci); 141 139 142 140 /* Unlike other USB host controller types, EHCI doesn't have ··· 172 170 } 173 171 } 174 172 173 + /* Apparently some devices need a >= 1-uframe delay here */ 174 + if (ehci->bus_suspended) 175 + udelay(150); 176 + 175 177 /* turn off now-idle HC */ 176 - del_timer_sync (&ehci->watchdog); 177 178 ehci_halt (ehci); 178 179 hcd->state = HC_STATE_SUSPENDED; 179 180 ··· 296 291 /*-------------------------------------------------------------------------*/ 297 292 298 293 /* Display the ports dedicated to the companion controller */ 299 - static ssize_t show_companion(struct class_device *class_dev, char *buf) 294 + static ssize_t show_companion(struct device *dev, 295 + struct device_attribute *attr, 296 + char *buf) 300 297 { 301 298 struct ehci_hcd *ehci; 302 299 int nports, index, n; 303 300 int count = PAGE_SIZE; 304 301 char *ptr = buf; 305 302 306 - ehci = hcd_to_ehci(bus_to_hcd(class_get_devdata(class_dev))); 303 + ehci = hcd_to_ehci(bus_to_hcd(dev_get_drvdata(dev))); 307 304 nports = HCS_N_PORTS(ehci->hcs_params); 308 305 309 306 for (index = 0; index < nports; ++index) { ··· 319 312 } 320 313 321 314 /* 322 - * Dedicate or undedicate a port to the companion controller. 323 - * Syntax is "[-]portnum", where a leading '-' sign means 324 - * return control of the port to the EHCI controller. 315 + * Sets the owner of a port 325 316 */ 326 - static ssize_t store_companion(struct class_device *class_dev, 327 - const char *buf, size_t count) 317 + static void set_owner(struct ehci_hcd *ehci, int portnum, int new_owner) 328 318 { 329 - struct ehci_hcd *ehci; 330 - int portnum, new_owner, try; 331 319 u32 __iomem *status_reg; 332 320 u32 port_status; 321 + int try; 333 322 334 - ehci = hcd_to_ehci(bus_to_hcd(class_get_devdata(class_dev))); 335 - new_owner = PORT_OWNER; /* Owned by companion */ 336 - if (sscanf(buf, "%d", &portnum) != 1) 337 - return -EINVAL; 338 - if (portnum < 0) { 339 - portnum = - portnum; 340 - new_owner = 0; /* Owned by EHCI */ 341 - } 342 - if (portnum <= 0 || portnum > HCS_N_PORTS(ehci->hcs_params)) 343 - return -ENOENT; 344 - status_reg = &ehci->regs->port_status[--portnum]; 345 - if (new_owner) 346 - set_bit(portnum, &ehci->companion_ports); 347 - else 348 - clear_bit(portnum, &ehci->companion_ports); 323 + status_reg = &ehci->regs->port_status[portnum]; 349 324 350 325 /* 351 326 * The controller won't set the OWNER bit if the port is 352 327 * enabled, so this loop will sometimes require at least two 353 328 * iterations: one to disable the port and one to set OWNER. 354 329 */ 355 - 356 330 for (try = 4; try > 0; --try) { 357 331 spin_lock_irq(&ehci->lock); 358 332 port_status = ehci_readl(ehci, status_reg); ··· 350 362 if (try > 1) 351 363 msleep(5); 352 364 } 365 + } 366 + 367 + /* 368 + * Dedicate or undedicate a port to the companion controller. 369 + * Syntax is "[-]portnum", where a leading '-' sign means 370 + * return control of the port to the EHCI controller. 371 + */ 372 + static ssize_t store_companion(struct device *dev, 373 + struct device_attribute *attr, 374 + const char *buf, size_t count) 375 + { 376 + struct ehci_hcd *ehci; 377 + int portnum, new_owner; 378 + 379 + ehci = hcd_to_ehci(bus_to_hcd(dev_get_drvdata(dev))); 380 + new_owner = PORT_OWNER; /* Owned by companion */ 381 + if (sscanf(buf, "%d", &portnum) != 1) 382 + return -EINVAL; 383 + if (portnum < 0) { 384 + portnum = - portnum; 385 + new_owner = 0; /* Owned by EHCI */ 386 + } 387 + if (portnum <= 0 || portnum > HCS_N_PORTS(ehci->hcs_params)) 388 + return -ENOENT; 389 + portnum--; 390 + if (new_owner) 391 + set_bit(portnum, &ehci->companion_ports); 392 + else 393 + clear_bit(portnum, &ehci->companion_ports); 394 + set_owner(ehci, portnum, new_owner); 353 395 return count; 354 396 } 355 - static CLASS_DEVICE_ATTR(companion, 0644, show_companion, store_companion); 397 + static DEVICE_ATTR(companion, 0644, show_companion, store_companion); 356 398 357 399 static inline void create_companion_file(struct ehci_hcd *ehci) 358 400 { ··· 390 372 391 373 /* with integrated TT there is no companion! */ 392 374 if (!ehci_is_TDI(ehci)) 393 - i = class_device_create_file(ehci_to_hcd(ehci)->self.class_dev, 394 - &class_device_attr_companion); 375 + i = device_create_file(ehci_to_hcd(ehci)->self.dev, 376 + &dev_attr_companion); 395 377 } 396 378 397 379 static inline void remove_companion_file(struct ehci_hcd *ehci) 398 380 { 399 381 /* with integrated TT there is no companion! */ 400 382 if (!ehci_is_TDI(ehci)) 401 - class_device_remove_file(ehci_to_hcd(ehci)->self.class_dev, 402 - &class_device_attr_companion); 383 + device_remove_file(ehci_to_hcd(ehci)->self.dev, 384 + &dev_attr_companion); 403 385 } 404 386 405 387 ··· 411 393 u32 __iomem *status_reg, 412 394 int port_status 413 395 ) { 414 - if (!(port_status & PORT_CONNECT)) { 415 - ehci->reset_done [index] = 0; 396 + if (!(port_status & PORT_CONNECT)) 416 397 return port_status; 417 - } 418 398 419 399 /* if reset finished and it's still not enabled -- handoff */ 420 400 if (!(port_status & PORT_PE)) { ··· 491 475 * controller by the user. 492 476 */ 493 477 494 - if (!(temp & PORT_CONNECT)) 495 - ehci->reset_done [i] = 0; 496 478 if ((temp & mask) != 0 497 479 || ((temp & PORT_RESUME) != 0 498 480 && time_after_eq(jiffies, ··· 878 864 spin_unlock_irqrestore (&ehci->lock, flags); 879 865 return retval; 880 866 } 867 + 868 + static void ehci_relinquish_port(struct usb_hcd *hcd, int portnum) 869 + { 870 + struct ehci_hcd *ehci = hcd_to_ehci(hcd); 871 + 872 + if (ehci_is_TDI(ehci)) 873 + return; 874 + set_owner(ehci, --portnum, PORT_OWNER); 875 + } 876 +
+152
drivers/usb/host/ehci-ixp4xx.c
··· 1 + /* 2 + * IXP4XX EHCI Host Controller Driver 3 + * 4 + * Author: Vladimir Barinov <vbarinov@ru.mvista.com> 5 + * 6 + * Based on "ehci-fsl.c" by Randy Vinson <rvinson@mvista.com> 7 + * 8 + * 2007 (c) MontaVista Software, Inc. This file is licensed under 9 + * the terms of the GNU General Public License version 2. This program 10 + * is licensed "as is" without any warranty of any kind, whether express 11 + * or implied. 12 + */ 13 + 14 + #include <linux/platform_device.h> 15 + 16 + static int ixp4xx_ehci_init(struct usb_hcd *hcd) 17 + { 18 + struct ehci_hcd *ehci = hcd_to_ehci(hcd); 19 + int retval = 0; 20 + 21 + ehci->big_endian_desc = 1; 22 + ehci->big_endian_mmio = 1; 23 + 24 + ehci->caps = hcd->regs + 0x100; 25 + ehci->regs = hcd->regs + 0x100 26 + + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase)); 27 + ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); 28 + 29 + ehci->is_tdi_rh_tt = 1; 30 + ehci_reset(ehci); 31 + 32 + retval = ehci_init(hcd); 33 + if (retval) 34 + return retval; 35 + 36 + ehci_port_power(ehci, 0); 37 + 38 + return retval; 39 + } 40 + 41 + static const struct hc_driver ixp4xx_ehci_hc_driver = { 42 + .description = hcd_name, 43 + .product_desc = "IXP4XX EHCI Host Controller", 44 + .hcd_priv_size = sizeof(struct ehci_hcd), 45 + .irq = ehci_irq, 46 + .flags = HCD_MEMORY | HCD_USB2, 47 + .reset = ixp4xx_ehci_init, 48 + .start = ehci_run, 49 + .stop = ehci_stop, 50 + .shutdown = ehci_shutdown, 51 + .urb_enqueue = ehci_urb_enqueue, 52 + .urb_dequeue = ehci_urb_dequeue, 53 + .endpoint_disable = ehci_endpoint_disable, 54 + .get_frame_number = ehci_get_frame, 55 + .hub_status_data = ehci_hub_status_data, 56 + .hub_control = ehci_hub_control, 57 + #if defined(CONFIG_PM) 58 + .bus_suspend = ehci_bus_suspend, 59 + .bus_resume = ehci_bus_resume, 60 + #endif 61 + }; 62 + 63 + static int ixp4xx_ehci_probe(struct platform_device *pdev) 64 + { 65 + struct usb_hcd *hcd; 66 + const struct hc_driver *driver = &ixp4xx_ehci_hc_driver; 67 + struct resource *res; 68 + int irq; 69 + int retval; 70 + 71 + if (usb_disabled()) 72 + return -ENODEV; 73 + 74 + res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 75 + if (!res) { 76 + dev_err(&pdev->dev, 77 + "Found HC with no IRQ. Check %s setup!\n", 78 + pdev->dev.bus_id); 79 + return -ENODEV; 80 + } 81 + irq = res->start; 82 + 83 + hcd = usb_create_hcd(driver, &pdev->dev, pdev->dev.bus_id); 84 + if (!hcd) { 85 + retval = -ENOMEM; 86 + goto fail_create_hcd; 87 + } 88 + 89 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 90 + if (!res) { 91 + dev_err(&pdev->dev, 92 + "Found HC with no register addr. Check %s setup!\n", 93 + pdev->dev.bus_id); 94 + retval = -ENODEV; 95 + goto fail_request_resource; 96 + } 97 + hcd->rsrc_start = res->start; 98 + hcd->rsrc_len = res->end - res->start + 1; 99 + 100 + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, 101 + driver->description)) { 102 + dev_dbg(&pdev->dev, "controller already in use\n"); 103 + retval = -EBUSY; 104 + goto fail_request_resource; 105 + } 106 + 107 + hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); 108 + if (hcd->regs == NULL) { 109 + dev_dbg(&pdev->dev, "error mapping memory\n"); 110 + retval = -EFAULT; 111 + goto fail_ioremap; 112 + } 113 + 114 + retval = usb_add_hcd(hcd, irq, IRQF_SHARED); 115 + if (retval) 116 + goto fail_add_hcd; 117 + 118 + return retval; 119 + 120 + fail_add_hcd: 121 + iounmap(hcd->regs); 122 + fail_ioremap: 123 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 124 + fail_request_resource: 125 + usb_put_hcd(hcd); 126 + fail_create_hcd: 127 + dev_err(&pdev->dev, "init %s fail, %d\n", pdev->dev.bus_id, retval); 128 + return retval; 129 + } 130 + 131 + static int ixp4xx_ehci_remove(struct platform_device *pdev) 132 + { 133 + struct usb_hcd *hcd = platform_get_drvdata(pdev); 134 + 135 + usb_remove_hcd(hcd); 136 + iounmap(hcd->regs); 137 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 138 + usb_put_hcd(hcd); 139 + 140 + return 0; 141 + } 142 + 143 + MODULE_ALIAS("ixp4xx-ehci"); 144 + 145 + static struct platform_driver ixp4xx_ehci_driver = { 146 + .probe = ixp4xx_ehci_probe, 147 + .remove = ixp4xx_ehci_remove, 148 + .driver = { 149 + .name = "ixp4xx-ehci", 150 + .bus = &platform_bus_type 151 + }, 152 + };
+272
drivers/usb/host/ehci-orion.c
··· 1 + /* 2 + * drivers/usb/host/ehci-orion.c 3 + * 4 + * Tzachi Perelstein <tzachi@marvell.com> 5 + * 6 + * This file is licensed under the terms of the GNU General Public 7 + * License version 2. This program is licensed "as is" without any 8 + * warranty of any kind, whether express or implied. 9 + */ 10 + 11 + #include <linux/kernel.h> 12 + #include <linux/module.h> 13 + #include <linux/platform_device.h> 14 + #include <asm/arch/orion.h> 15 + 16 + #define rdl(off) __raw_readl(hcd->regs + (off)) 17 + #define wrl(off, val) __raw_writel((val), hcd->regs + (off)) 18 + 19 + #define USB_CAUSE 0x310 20 + #define USB_MASK 0x314 21 + #define USB_CMD 0x140 22 + #define USB_MODE 0x1a8 23 + #define USB_IPG 0x360 24 + #define USB_PHY_PWR_CTRL 0x400 25 + #define USB_PHY_TX_CTRL 0x420 26 + #define USB_PHY_RX_CTRL 0x430 27 + #define USB_PHY_IVREF_CTRL 0x440 28 + #define USB_PHY_TST_GRP_CTRL 0x450 29 + 30 + /* 31 + * Implement Orion USB controller specification guidelines 32 + */ 33 + static void orion_usb_setup(struct usb_hcd *hcd) 34 + { 35 + /* 36 + * Clear interrupt cause and mask 37 + */ 38 + wrl(USB_CAUSE, 0); 39 + wrl(USB_MASK, 0); 40 + 41 + /* 42 + * Reset controller 43 + */ 44 + wrl(USB_CMD, rdl(USB_CMD) | 0x2); 45 + while (rdl(USB_CMD) & 0x2); 46 + 47 + /* 48 + * GL# USB-10: Set IPG for non start of frame packets 49 + * Bits[14:8]=0xc 50 + */ 51 + wrl(USB_IPG, (rdl(USB_IPG) & ~0x7f00) | 0xc00); 52 + 53 + /* 54 + * GL# USB-9: USB 2.0 Power Control 55 + * BG_VSEL[7:6]=0x1 56 + */ 57 + wrl(USB_PHY_PWR_CTRL, (rdl(USB_PHY_PWR_CTRL) & ~0xc0)| 0x40); 58 + 59 + /* 60 + * GL# USB-1: USB PHY Tx Control - force calibration to '8' 61 + * TXDATA_BLOCK_EN[21]=0x1, EXT_RCAL_EN[13]=0x1, IMP_CAL[6:3]=0x8 62 + */ 63 + wrl(USB_PHY_TX_CTRL, (rdl(USB_PHY_TX_CTRL) & ~0x78) | 0x202040); 64 + 65 + /* 66 + * GL# USB-3 GL# USB-9: USB PHY Rx Control 67 + * RXDATA_BLOCK_LENGHT[31:30]=0x3, EDGE_DET_SEL[27:26]=0, 68 + * CDR_FASTLOCK_EN[21]=0, DISCON_THRESHOLD[9:8]=0, SQ_THRESH[7:4]=0x1 69 + */ 70 + wrl(USB_PHY_RX_CTRL, (rdl(USB_PHY_RX_CTRL) & ~0xc2003f0) | 0xc0000010); 71 + 72 + /* 73 + * GL# USB-3 GL# USB-9: USB PHY IVREF Control 74 + * PLLVDD12[1:0]=0x2, RXVDD[5:4]=0x3, Reserved[19]=0 75 + */ 76 + wrl(USB_PHY_IVREF_CTRL, (rdl(USB_PHY_IVREF_CTRL) & ~0x80003 ) | 0x32); 77 + 78 + /* 79 + * GL# USB-3 GL# USB-9: USB PHY Test Group Control 80 + * REG_FIFO_SQ_RST[15]=0 81 + */ 82 + wrl(USB_PHY_TST_GRP_CTRL, rdl(USB_PHY_TST_GRP_CTRL) & ~0x8000); 83 + 84 + /* 85 + * Stop and reset controller 86 + */ 87 + wrl(USB_CMD, rdl(USB_CMD) & ~0x1); 88 + wrl(USB_CMD, rdl(USB_CMD) | 0x2); 89 + while (rdl(USB_CMD) & 0x2); 90 + 91 + /* 92 + * GL# USB-5 Streaming disable REG_USB_MODE[4]=1 93 + * TBD: This need to be done after each reset! 94 + * GL# USB-4 Setup USB Host mode 95 + */ 96 + wrl(USB_MODE, 0x13); 97 + } 98 + 99 + static int ehci_orion_setup(struct usb_hcd *hcd) 100 + { 101 + struct ehci_hcd *ehci = hcd_to_ehci(hcd); 102 + int retval; 103 + 104 + retval = ehci_halt(ehci); 105 + if (retval) 106 + return retval; 107 + 108 + /* 109 + * data structure init 110 + */ 111 + retval = ehci_init(hcd); 112 + if (retval) 113 + return retval; 114 + 115 + ehci_reset(ehci); 116 + ehci_port_power(ehci, 0); 117 + 118 + return retval; 119 + } 120 + 121 + static const struct hc_driver ehci_orion_hc_driver = { 122 + .description = hcd_name, 123 + .product_desc = "Marvell Orion EHCI", 124 + .hcd_priv_size = sizeof(struct ehci_hcd), 125 + 126 + /* 127 + * generic hardware linkage 128 + */ 129 + .irq = ehci_irq, 130 + .flags = HCD_MEMORY | HCD_USB2, 131 + 132 + /* 133 + * basic lifecycle operations 134 + */ 135 + .reset = ehci_orion_setup, 136 + .start = ehci_run, 137 + #ifdef CONFIG_PM 138 + .suspend = ehci_bus_suspend, 139 + .resume = ehci_bus_resume, 140 + #endif 141 + .stop = ehci_stop, 142 + .shutdown = ehci_shutdown, 143 + 144 + /* 145 + * managing i/o requests and associated device resources 146 + */ 147 + .urb_enqueue = ehci_urb_enqueue, 148 + .urb_dequeue = ehci_urb_dequeue, 149 + .endpoint_disable = ehci_endpoint_disable, 150 + 151 + /* 152 + * scheduling support 153 + */ 154 + .get_frame_number = ehci_get_frame, 155 + 156 + /* 157 + * root hub support 158 + */ 159 + .hub_status_data = ehci_hub_status_data, 160 + .hub_control = ehci_hub_control, 161 + .bus_suspend = ehci_bus_suspend, 162 + .bus_resume = ehci_bus_resume, 163 + }; 164 + 165 + static int __init ehci_orion_drv_probe(struct platform_device *pdev) 166 + { 167 + struct resource *res; 168 + struct usb_hcd *hcd; 169 + struct ehci_hcd *ehci; 170 + void __iomem *regs; 171 + int irq, err; 172 + 173 + if (usb_disabled()) 174 + return -ENODEV; 175 + 176 + pr_debug("Initializing Orion-SoC USB Host Controller\n"); 177 + 178 + irq = platform_get_irq(pdev, 0); 179 + if (irq <= 0) { 180 + dev_err(&pdev->dev, 181 + "Found HC with no IRQ. Check %s setup!\n", 182 + pdev->dev.bus_id); 183 + err = -ENODEV; 184 + goto err1; 185 + } 186 + 187 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 188 + if (!res) { 189 + dev_err(&pdev->dev, 190 + "Found HC with no register addr. Check %s setup!\n", 191 + pdev->dev.bus_id); 192 + err = -ENODEV; 193 + goto err1; 194 + } 195 + 196 + if (!request_mem_region(res->start, res->end - res->start + 1, 197 + ehci_orion_hc_driver.description)) { 198 + dev_dbg(&pdev->dev, "controller already in use\n"); 199 + err = -EBUSY; 200 + goto err1; 201 + } 202 + 203 + regs = ioremap(res->start, res->end - res->start + 1); 204 + if (regs == NULL) { 205 + dev_dbg(&pdev->dev, "error mapping memory\n"); 206 + err = -EFAULT; 207 + goto err2; 208 + } 209 + 210 + hcd = usb_create_hcd(&ehci_orion_hc_driver, 211 + &pdev->dev, pdev->dev.bus_id); 212 + if (!hcd) { 213 + err = -ENOMEM; 214 + goto err3; 215 + } 216 + 217 + hcd->rsrc_start = res->start; 218 + hcd->rsrc_len = res->end - res->start + 1; 219 + hcd->regs = regs; 220 + 221 + ehci = hcd_to_ehci(hcd); 222 + ehci->caps = hcd->regs + 0x100; 223 + ehci->regs = hcd->regs + 0x100 + 224 + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase)); 225 + ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); 226 + ehci->is_tdi_rh_tt = 1; 227 + ehci->sbrn = 0x20; 228 + 229 + /* 230 + * setup Orion USB controller 231 + */ 232 + orion_usb_setup(hcd); 233 + 234 + err = usb_add_hcd(hcd, irq, IRQF_SHARED | IRQF_DISABLED); 235 + if (err) 236 + goto err4; 237 + 238 + return 0; 239 + 240 + err4: 241 + usb_put_hcd(hcd); 242 + err3: 243 + iounmap(regs); 244 + err2: 245 + release_mem_region(res->start, res->end - res->start + 1); 246 + err1: 247 + dev_err(&pdev->dev, "init %s fail, %d\n", 248 + pdev->dev.bus_id, err); 249 + 250 + return err; 251 + } 252 + 253 + static int __exit ehci_orion_drv_remove(struct platform_device *pdev) 254 + { 255 + struct usb_hcd *hcd = platform_get_drvdata(pdev); 256 + 257 + usb_remove_hcd(hcd); 258 + iounmap(hcd->regs); 259 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 260 + usb_put_hcd(hcd); 261 + 262 + return 0; 263 + } 264 + 265 + MODULE_ALIAS("platform:orion-ehci"); 266 + 267 + static struct platform_driver ehci_orion_driver = { 268 + .probe = ehci_orion_drv_probe, 269 + .remove = __exit_p(ehci_orion_drv_remove), 270 + .shutdown = usb_hcd_platform_shutdown, 271 + .driver.name = "orion-ehci", 272 + };
+2 -1
drivers/usb/host/ehci-pci.c
··· 305 305 /* emptying the schedule aborts any urbs */ 306 306 spin_lock_irq(&ehci->lock); 307 307 if (ehci->reclaim) 308 - ehci->reclaim_ready = 1; 308 + end_unlink_async(ehci); 309 309 ehci_work(ehci); 310 310 spin_unlock_irq(&ehci->lock); 311 311 ··· 364 364 .hub_control = ehci_hub_control, 365 365 .bus_suspend = ehci_bus_suspend, 366 366 .bus_resume = ehci_bus_resume, 367 + .relinquish_port = ehci_relinquish_port, 367 368 }; 368 369 369 370 /*-------------------------------------------------------------------------*/
+238
drivers/usb/host/ehci-ppc-of.c
··· 1 + /* 2 + * EHCI HCD (Host Controller Driver) for USB. 3 + * 4 + * Bus Glue for PPC On-Chip EHCI driver on the of_platform bus 5 + * Tested on AMCC PPC 440EPx 6 + * 7 + * Valentine Barshak <vbarshak@ru.mvista.com> 8 + * 9 + * Based on "ehci-ppc-soc.c" by Stefan Roese <sr@denx.de> 10 + * and "ohci-ppc-of.c" by Sylvain Munaut <tnt@246tNt.com> 11 + * 12 + * This file is licenced under the GPL. 13 + */ 14 + 15 + #include <linux/signal.h> 16 + 17 + #include <linux/of.h> 18 + #include <linux/of_platform.h> 19 + 20 + /* called during probe() after chip reset completes */ 21 + static int ehci_ppc_of_setup(struct usb_hcd *hcd) 22 + { 23 + struct ehci_hcd *ehci = hcd_to_ehci(hcd); 24 + int retval; 25 + 26 + retval = ehci_halt(ehci); 27 + if (retval) 28 + return retval; 29 + 30 + retval = ehci_init(hcd); 31 + if (retval) 32 + return retval; 33 + 34 + ehci->sbrn = 0x20; 35 + return ehci_reset(ehci); 36 + } 37 + 38 + 39 + static const struct hc_driver ehci_ppc_of_hc_driver = { 40 + .description = hcd_name, 41 + .product_desc = "OF EHCI", 42 + .hcd_priv_size = sizeof(struct ehci_hcd), 43 + 44 + /* 45 + * generic hardware linkage 46 + */ 47 + .irq = ehci_irq, 48 + .flags = HCD_MEMORY | HCD_USB2, 49 + 50 + /* 51 + * basic lifecycle operations 52 + */ 53 + .reset = ehci_ppc_of_setup, 54 + .start = ehci_run, 55 + .stop = ehci_stop, 56 + .shutdown = ehci_shutdown, 57 + 58 + /* 59 + * managing i/o requests and associated device resources 60 + */ 61 + .urb_enqueue = ehci_urb_enqueue, 62 + .urb_dequeue = ehci_urb_dequeue, 63 + .endpoint_disable = ehci_endpoint_disable, 64 + 65 + /* 66 + * scheduling support 67 + */ 68 + .get_frame_number = ehci_get_frame, 69 + 70 + /* 71 + * root hub support 72 + */ 73 + .hub_status_data = ehci_hub_status_data, 74 + .hub_control = ehci_hub_control, 75 + #ifdef CONFIG_PM 76 + .bus_suspend = ehci_bus_suspend, 77 + .bus_resume = ehci_bus_resume, 78 + #endif 79 + }; 80 + 81 + 82 + /* 83 + * 440EPx Errata USBH_3 84 + * Fix: Enable Break Memory Transfer (BMT) in INSNREG3 85 + */ 86 + #define PPC440EPX_EHCI0_INSREG_BMT (0x1 << 0) 87 + static int __devinit 88 + ppc44x_enable_bmt(struct device_node *dn) 89 + { 90 + __iomem u32 *insreg_virt; 91 + 92 + insreg_virt = of_iomap(dn, 1); 93 + if (!insreg_virt) 94 + return -EINVAL; 95 + 96 + out_be32(insreg_virt + 3, PPC440EPX_EHCI0_INSREG_BMT); 97 + 98 + iounmap(insreg_virt); 99 + return 0; 100 + } 101 + 102 + 103 + static int __devinit 104 + ehci_hcd_ppc_of_probe(struct of_device *op, const struct of_device_id *match) 105 + { 106 + struct device_node *dn = op->node; 107 + struct usb_hcd *hcd; 108 + struct ehci_hcd *ehci; 109 + struct resource res; 110 + int irq; 111 + int rv; 112 + 113 + if (usb_disabled()) 114 + return -ENODEV; 115 + 116 + dev_dbg(&op->dev, "initializing PPC-OF USB Controller\n"); 117 + 118 + rv = of_address_to_resource(dn, 0, &res); 119 + if (rv) 120 + return rv; 121 + 122 + hcd = usb_create_hcd(&ehci_ppc_of_hc_driver, &op->dev, "PPC-OF USB"); 123 + if (!hcd) 124 + return -ENOMEM; 125 + 126 + hcd->rsrc_start = res.start; 127 + hcd->rsrc_len = res.end - res.start + 1; 128 + 129 + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 130 + printk(KERN_ERR __FILE__ ": request_mem_region failed\n"); 131 + rv = -EBUSY; 132 + goto err_rmr; 133 + } 134 + 135 + irq = irq_of_parse_and_map(dn, 0); 136 + if (irq == NO_IRQ) { 137 + printk(KERN_ERR __FILE__ ": irq_of_parse_and_map failed\n"); 138 + rv = -EBUSY; 139 + goto err_irq; 140 + } 141 + 142 + hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); 143 + if (!hcd->regs) { 144 + printk(KERN_ERR __FILE__ ": ioremap failed\n"); 145 + rv = -ENOMEM; 146 + goto err_ioremap; 147 + } 148 + 149 + ehci = hcd_to_ehci(hcd); 150 + 151 + if (of_get_property(dn, "big-endian", NULL)) { 152 + ehci->big_endian_mmio = 1; 153 + ehci->big_endian_desc = 1; 154 + } 155 + if (of_get_property(dn, "big-endian-regs", NULL)) 156 + ehci->big_endian_mmio = 1; 157 + if (of_get_property(dn, "big-endian-desc", NULL)) 158 + ehci->big_endian_desc = 1; 159 + 160 + ehci->caps = hcd->regs; 161 + ehci->regs = hcd->regs + 162 + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase)); 163 + 164 + /* cache this readonly data; minimize chip reads */ 165 + ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); 166 + 167 + if (of_device_is_compatible(dn, "ibm,usb-ehci-440epx")) { 168 + rv = ppc44x_enable_bmt(dn); 169 + ehci_dbg(ehci, "Break Memory Transfer (BMT) is %senabled!\n", 170 + rv ? "NOT ": ""); 171 + } 172 + 173 + rv = usb_add_hcd(hcd, irq, 0); 174 + if (rv == 0) 175 + return 0; 176 + 177 + iounmap(hcd->regs); 178 + err_ioremap: 179 + irq_dispose_mapping(irq); 180 + err_irq: 181 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 182 + err_rmr: 183 + usb_put_hcd(hcd); 184 + 185 + return rv; 186 + } 187 + 188 + 189 + static int ehci_hcd_ppc_of_remove(struct of_device *op) 190 + { 191 + struct usb_hcd *hcd = dev_get_drvdata(&op->dev); 192 + dev_set_drvdata(&op->dev, NULL); 193 + 194 + dev_dbg(&op->dev, "stopping PPC-OF USB Controller\n"); 195 + 196 + usb_remove_hcd(hcd); 197 + 198 + iounmap(hcd->regs); 199 + irq_dispose_mapping(hcd->irq); 200 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 201 + 202 + usb_put_hcd(hcd); 203 + 204 + return 0; 205 + } 206 + 207 + 208 + static int ehci_hcd_ppc_of_shutdown(struct of_device *op) 209 + { 210 + struct usb_hcd *hcd = dev_get_drvdata(&op->dev); 211 + 212 + if (hcd->driver->shutdown) 213 + hcd->driver->shutdown(hcd); 214 + 215 + return 0; 216 + } 217 + 218 + 219 + static struct of_device_id ehci_hcd_ppc_of_match[] = { 220 + { 221 + .compatible = "usb-ehci", 222 + }, 223 + {}, 224 + }; 225 + MODULE_DEVICE_TABLE(of, ehci_hcd_ppc_of_match); 226 + 227 + 228 + static struct of_platform_driver ehci_hcd_ppc_of_driver = { 229 + .name = "ppc-of-ehci", 230 + .match_table = ehci_hcd_ppc_of_match, 231 + .probe = ehci_hcd_ppc_of_probe, 232 + .remove = ehci_hcd_ppc_of_remove, 233 + .shutdown = ehci_hcd_ppc_of_shutdown, 234 + .driver = { 235 + .name = "ppc-of-ehci", 236 + .owner = THIS_MODULE, 237 + }, 238 + };
+1
drivers/usb/host/ehci-ppc-soc.c
··· 162 162 .hub_control = ehci_hub_control, 163 163 .bus_suspend = ehci_bus_suspend, 164 164 .bus_resume = ehci_bus_resume, 165 + .relinquish_port = ehci_relinquish_port, 165 166 }; 166 167 167 168 static int ehci_hcd_ppc_soc_drv_probe(struct platform_device *pdev)
+1
drivers/usb/host/ehci-ps3.c
··· 72 72 .bus_suspend = ehci_bus_suspend, 73 73 .bus_resume = ehci_bus_resume, 74 74 #endif 75 + .relinquish_port = ehci_relinquish_port, 75 76 }; 76 77 77 78 static int ps3_ehci_probe(struct ps3_system_bus_device *dev)
+13 -12
drivers/usb/host/ehci-q.c
··· 198 198 199 199 /* if async CSPLIT failed, try cleaning out the TT buffer */ 200 200 if (status != -EPIPE 201 - && urb->dev->tt && !usb_pipeint (urb->pipe) 201 + && urb->dev->tt 202 + && !usb_pipeint(urb->pipe) 202 203 && ((token & QTD_STS_MMF) != 0 203 204 || QTD_CERR(token) == 0) 204 205 && (!ehci_is_TDI(ehci) ··· 212 211 urb->dev->ttport, urb->dev->devnum, 213 212 usb_pipeendpoint (urb->pipe), token); 214 213 #endif /* DEBUG */ 214 + /* REVISIT ARC-derived cores don't clear the root 215 + * hub TT buffer in this way... 216 + */ 215 217 usb_hub_tt_clear_buffer (urb->dev, urb->pipe); 216 218 } 217 219 } ··· 642 638 u32 info1 = 0, info2 = 0; 643 639 int is_input, type; 644 640 int maxp = 0; 641 + struct usb_tt *tt = urb->dev->tt; 645 642 646 643 if (!qh) 647 644 return qh; ··· 666 661 * For control/bulk requests, the HC or TT handles these. 667 662 */ 668 663 if (type == PIPE_INTERRUPT) { 669 - qh->usecs = NS_TO_US (usb_calc_bus_time (USB_SPEED_HIGH, is_input, 0, 670 - hb_mult (maxp) * max_packet (maxp))); 664 + qh->usecs = NS_TO_US(usb_calc_bus_time(USB_SPEED_HIGH, 665 + is_input, 0, 666 + hb_mult(maxp) * max_packet(maxp))); 671 667 qh->start = NO_FRAME; 672 668 673 669 if (urb->dev->speed == USB_SPEED_HIGH) { ··· 686 680 goto done; 687 681 } 688 682 } else { 689 - struct usb_tt *tt = urb->dev->tt; 690 683 int think_time; 691 684 692 685 /* gap is f(FS/LS transfer times) */ ··· 741 736 /* set the address of the TT; for TDI's integrated 742 737 * root hub tt, leave it zeroed. 743 738 */ 744 - if (!ehci_is_TDI(ehci) 745 - || urb->dev->tt->hub != 746 - ehci_to_hcd(ehci)->self.root_hub) 747 - info2 |= urb->dev->tt->hub->devnum << 16; 739 + if (tt && tt->hub != ehci_to_hcd(ehci)->self.root_hub) 740 + info2 |= tt->hub->devnum << 16; 748 741 749 742 /* NOTE: if (PIPE_INTERRUPT) { scheduler sets c-mask } */ 750 743 ··· 976 973 struct ehci_qh *qh = ehci->reclaim; 977 974 struct ehci_qh *next; 978 975 979 - timer_action_done (ehci, TIMER_IAA_WATCHDOG); 976 + iaa_watchdog_done(ehci); 980 977 981 978 // qh->hw_next = cpu_to_hc32(qh->qh_dma); 982 979 qh->qh_state = QH_STATE_IDLE; ··· 986 983 /* other unlink(s) may be pending (in QH_STATE_UNLINK_WAIT) */ 987 984 next = qh->reclaim; 988 985 ehci->reclaim = next; 989 - ehci->reclaim_ready = 0; 990 986 qh->reclaim = NULL; 991 987 992 988 qh_completions (ehci, qh); ··· 1061 1059 return; 1062 1060 } 1063 1061 1064 - ehci->reclaim_ready = 0; 1065 1062 cmd |= CMD_IAAD; 1066 1063 ehci_writel(ehci, cmd, &ehci->regs->command); 1067 1064 (void)ehci_readl(ehci, &ehci->regs->command); 1068 - timer_action (ehci, TIMER_IAA_WATCHDOG); 1065 + iaa_watchdog_start(ehci); 1069 1066 } 1070 1067 1071 1068 /*-------------------------------------------------------------------------*/
+84 -68
drivers/usb/host/ehci-sched.c
··· 119 119 q = &q->fstn->fstn_next; 120 120 break; 121 121 case Q_TYPE_ITD: 122 - usecs += q->itd->usecs [uframe]; 122 + if (q->itd->hw_transaction[uframe]) 123 + usecs += q->itd->stream->usecs; 123 124 hw_p = &q->itd->hw_next; 124 125 q = &q->itd->itd_next; 125 126 break; ··· 212 211 * low/fullspeed transfer can "carry over" from one uframe to the next, 213 212 * since the TT just performs downstream transfers in sequence. 214 213 * 215 - * For example two seperate 100 usec transfers can start in the same uframe, 214 + * For example two separate 100 usec transfers can start in the same uframe, 216 215 * and the second one would "carry over" 75 usecs into the next uframe. 217 216 */ 218 217 static void ··· 1537 1536 uframe = next_uframe & 0x07; 1538 1537 frame = next_uframe >> 3; 1539 1538 1540 - itd->usecs [uframe] = stream->usecs; 1541 1539 itd_patch(ehci, itd, iso_sched, packet, uframe); 1542 1540 1543 1541 next_uframe += stream->interval; ··· 1565 1565 1566 1566 #define ISO_ERRS (EHCI_ISOC_BUF_ERR | EHCI_ISOC_BABBLE | EHCI_ISOC_XACTERR) 1567 1567 1568 + /* Process and recycle a completed ITD. Return true iff its urb completed, 1569 + * and hence its completion callback probably added things to the hardware 1570 + * schedule. 1571 + * 1572 + * Note that we carefully avoid recycling this descriptor until after any 1573 + * completion callback runs, so that it won't be reused quickly. That is, 1574 + * assuming (a) no more than two urbs per frame on this endpoint, and also 1575 + * (b) only this endpoint's completions submit URBs. It seems some silicon 1576 + * corrupts things if you reuse completed descriptors very quickly... 1577 + */ 1568 1578 static unsigned 1569 1579 itd_complete ( 1570 1580 struct ehci_hcd *ehci, ··· 1587 1577 int urb_index = -1; 1588 1578 struct ehci_iso_stream *stream = itd->stream; 1589 1579 struct usb_device *dev; 1580 + unsigned retval = false; 1590 1581 1591 1582 /* for each uframe with a packet */ 1592 1583 for (uframe = 0; uframe < 8; uframe++) { ··· 1621 1610 } 1622 1611 } 1623 1612 1624 - usb_put_urb (urb); 1625 - itd->urb = NULL; 1626 - itd->stream = NULL; 1627 - list_move (&itd->itd_list, &stream->free_list); 1628 - iso_stream_put (ehci, stream); 1629 - 1630 1613 /* handle completion now? */ 1631 1614 if (likely ((urb_index + 1) != urb->number_of_packets)) 1632 - return 0; 1615 + goto done; 1633 1616 1634 1617 /* ASSERT: it's really the last itd for this urb 1635 1618 list_for_each_entry (itd, &stream->td_list, itd_list) 1636 1619 BUG_ON (itd->urb == urb); 1637 1620 */ 1638 1621 1639 - /* give urb back to the driver ... can be out-of-order */ 1622 + /* give urb back to the driver; completion often (re)submits */ 1640 1623 dev = urb->dev; 1641 1624 ehci_urb_done(ehci, urb, 0); 1625 + retval = true; 1642 1626 urb = NULL; 1643 - 1644 - /* defer stopping schedule; completion can submit */ 1645 1627 ehci->periodic_sched--; 1646 - if (unlikely (!ehci->periodic_sched)) 1647 - (void) disable_periodic (ehci); 1648 1628 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--; 1649 1629 1650 1630 if (unlikely (list_empty (&stream->td_list))) { ··· 1647 1645 (stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out"); 1648 1646 } 1649 1647 iso_stream_put (ehci, stream); 1648 + /* OK to recycle this ITD now that its completion callback ran. */ 1649 + done: 1650 + usb_put_urb(urb); 1651 + itd->urb = NULL; 1652 + itd->stream = NULL; 1653 + list_move(&itd->itd_list, &stream->free_list); 1654 + iso_stream_put(ehci, stream); 1650 1655 1651 - return 1; 1656 + return retval; 1652 1657 } 1653 1658 1654 1659 /*-------------------------------------------------------------------------*/ ··· 1720 1711 iso_stream_put (ehci, stream); 1721 1712 return status; 1722 1713 } 1723 - 1724 - #ifdef CONFIG_USB_EHCI_SPLIT_ISO 1725 1714 1726 1715 /*-------------------------------------------------------------------------*/ 1727 1716 ··· 1957 1950 #define SITD_ERRS (SITD_STS_ERR | SITD_STS_DBE | SITD_STS_BABBLE \ 1958 1951 | SITD_STS_XACT | SITD_STS_MMF) 1959 1952 1953 + /* Process and recycle a completed SITD. Return true iff its urb completed, 1954 + * and hence its completion callback probably added things to the hardware 1955 + * schedule. 1956 + * 1957 + * Note that we carefully avoid recycling this descriptor until after any 1958 + * completion callback runs, so that it won't be reused quickly. That is, 1959 + * assuming (a) no more than two urbs per frame on this endpoint, and also 1960 + * (b) only this endpoint's completions submit URBs. It seems some silicon 1961 + * corrupts things if you reuse completed descriptors very quickly... 1962 + */ 1960 1963 static unsigned 1961 1964 sitd_complete ( 1962 1965 struct ehci_hcd *ehci, ··· 1978 1961 int urb_index = -1; 1979 1962 struct ehci_iso_stream *stream = sitd->stream; 1980 1963 struct usb_device *dev; 1964 + unsigned retval = false; 1981 1965 1982 1966 urb_index = sitd->index; 1983 1967 desc = &urb->iso_frame_desc [urb_index]; ··· 1999 1981 desc->status = 0; 2000 1982 desc->actual_length = desc->length - SITD_LENGTH (t); 2001 1983 } 2002 - 2003 - usb_put_urb (urb); 2004 - sitd->urb = NULL; 2005 - sitd->stream = NULL; 2006 - list_move (&sitd->sitd_list, &stream->free_list); 2007 1984 stream->depth -= stream->interval << 3; 2008 - iso_stream_put (ehci, stream); 2009 1985 2010 1986 /* handle completion now? */ 2011 1987 if ((urb_index + 1) != urb->number_of_packets) 2012 - return 0; 1988 + goto done; 2013 1989 2014 1990 /* ASSERT: it's really the last sitd for this urb 2015 1991 list_for_each_entry (sitd, &stream->td_list, sitd_list) 2016 1992 BUG_ON (sitd->urb == urb); 2017 1993 */ 2018 1994 2019 - /* give urb back to the driver */ 1995 + /* give urb back to the driver; completion often (re)submits */ 2020 1996 dev = urb->dev; 2021 1997 ehci_urb_done(ehci, urb, 0); 1998 + retval = true; 2022 1999 urb = NULL; 2023 - 2024 - /* defer stopping schedule; completion can submit */ 2025 2000 ehci->periodic_sched--; 2026 - if (!ehci->periodic_sched) 2027 - (void) disable_periodic (ehci); 2028 2001 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--; 2029 2002 2030 2003 if (list_empty (&stream->td_list)) { ··· 2027 2018 (stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out"); 2028 2019 } 2029 2020 iso_stream_put (ehci, stream); 2021 + /* OK to recycle this SITD now that its completion callback ran. */ 2022 + done: 2023 + usb_put_urb(urb); 2024 + sitd->urb = NULL; 2025 + sitd->stream = NULL; 2026 + list_move(&sitd->sitd_list, &stream->free_list); 2027 + iso_stream_put(ehci, stream); 2030 2028 2031 - return 1; 2029 + return retval; 2032 2030 } 2033 2031 2034 2032 ··· 2098 2082 return status; 2099 2083 } 2100 2084 2101 - #else 2102 - 2103 - static inline int 2104 - sitd_submit (struct ehci_hcd *ehci, struct urb *urb, gfp_t mem_flags) 2105 - { 2106 - ehci_dbg (ehci, "split iso support is disabled\n"); 2107 - return -ENOSYS; 2108 - } 2109 - 2110 - static inline unsigned 2111 - sitd_complete ( 2112 - struct ehci_hcd *ehci, 2113 - struct ehci_sitd *sitd 2114 - ) { 2115 - ehci_err (ehci, "sitd_complete %p?\n", sitd); 2116 - return 0; 2117 - } 2118 - 2119 - #endif /* USB_EHCI_SPLIT_ISO */ 2120 - 2121 2085 /*-------------------------------------------------------------------------*/ 2122 2086 2123 2087 static void ··· 2123 2127 for (;;) { 2124 2128 union ehci_shadow q, *q_p; 2125 2129 __hc32 type, *hw_p; 2126 - unsigned uframes; 2130 + unsigned incomplete = false; 2127 2131 2128 - /* don't scan past the live uframe */ 2129 2132 frame = now_uframe >> 3; 2130 - if (frame == (clock >> 3)) 2131 - uframes = now_uframe & 0x07; 2132 - else { 2133 - /* safe to scan the whole frame at once */ 2134 - now_uframe |= 0x07; 2135 - uframes = 8; 2136 - } 2137 2133 2138 2134 restart: 2139 2135 /* scan each element in frame's queue for completions */ ··· 2163 2175 q = q.fstn->fstn_next; 2164 2176 break; 2165 2177 case Q_TYPE_ITD: 2166 - /* skip itds for later in the frame */ 2178 + /* If this ITD is still active, leave it for 2179 + * later processing ... check the next entry. 2180 + */ 2167 2181 rmb (); 2168 - for (uf = live ? uframes : 8; uf < 8; uf++) { 2182 + for (uf = 0; uf < 8 && live; uf++) { 2169 2183 if (0 == (q.itd->hw_transaction [uf] 2170 2184 & ITD_ACTIVE(ehci))) 2171 2185 continue; 2186 + incomplete = true; 2172 2187 q_p = &q.itd->itd_next; 2173 2188 hw_p = &q.itd->hw_next; 2174 2189 type = Q_NEXT_TYPE(ehci, ··· 2179 2188 q = *q_p; 2180 2189 break; 2181 2190 } 2182 - if (uf != 8) 2191 + if (uf < 8 && live) 2183 2192 break; 2184 2193 2185 - /* this one's ready ... HC won't cache the 2194 + /* Take finished ITDs out of the schedule 2195 + * and process them: recycle, maybe report 2196 + * URB completion. HC won't cache the 2186 2197 * pointer for much longer, if at all. 2187 2198 */ 2188 2199 *q_p = q.itd->itd_next; ··· 2195 2202 q = *q_p; 2196 2203 break; 2197 2204 case Q_TYPE_SITD: 2205 + /* If this SITD is still active, leave it for 2206 + * later processing ... check the next entry. 2207 + */ 2198 2208 if ((q.sitd->hw_results & SITD_ACTIVE(ehci)) 2199 2209 && live) { 2210 + incomplete = true; 2200 2211 q_p = &q.sitd->sitd_next; 2201 2212 hw_p = &q.sitd->hw_next; 2202 2213 type = Q_NEXT_TYPE(ehci, ··· 2208 2211 q = *q_p; 2209 2212 break; 2210 2213 } 2214 + 2215 + /* Take finished SITDs out of the schedule 2216 + * and process them: recycle, maybe report 2217 + * URB completion. 2218 + */ 2211 2219 *q_p = q.sitd->sitd_next; 2212 2220 *hw_p = q.sitd->hw_next; 2213 2221 type = Q_NEXT_TYPE(ehci, q.sitd->hw_next); ··· 2228 2226 } 2229 2227 2230 2228 /* assume completion callbacks modify the queue */ 2231 - if (unlikely (modified)) 2232 - goto restart; 2229 + if (unlikely (modified)) { 2230 + if (likely(ehci->periodic_sched > 0)) 2231 + goto restart; 2232 + /* maybe we can short-circuit this scan! */ 2233 + disable_periodic(ehci); 2234 + now_uframe = clock; 2235 + break; 2236 + } 2233 2237 } 2234 2238 2235 - /* stop when we catch up to the HC */ 2239 + /* If we can tell we caught up to the hardware, stop now. 2240 + * We can't advance our scan without collecting the ISO 2241 + * transfers that are still pending in this frame. 2242 + */ 2243 + if (incomplete && HC_IS_RUNNING(ehci_to_hcd(ehci)->state)) { 2244 + ehci->next_uframe = now_uframe; 2245 + break; 2246 + } 2236 2247 2237 2248 // FIXME: this assumes we won't get lapped when 2238 2249 // latencies climb; that should be rare, but... ··· 2258 2243 if (now_uframe == clock) { 2259 2244 unsigned now; 2260 2245 2261 - if (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state)) 2246 + if (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state) 2247 + || ehci->periodic_sched == 0) 2262 2248 break; 2263 2249 ehci->next_uframe = now_uframe; 2264 2250 now = ehci_readl(ehci, &ehci->regs->frame_index) % mod;
+30 -10
drivers/usb/host/ehci.h
··· 74 74 /* async schedule support */ 75 75 struct ehci_qh *async; 76 76 struct ehci_qh *reclaim; 77 - unsigned reclaim_ready : 1; 78 77 unsigned scanning : 1; 79 78 80 79 /* periodic schedule support */ ··· 104 105 struct dma_pool *itd_pool; /* itd per iso urb */ 105 106 struct dma_pool *sitd_pool; /* sitd per split iso urb */ 106 107 108 + struct timer_list iaa_watchdog; 107 109 struct timer_list watchdog; 108 110 unsigned long actions; 109 111 unsigned stamp; ··· 127 127 #else 128 128 # define COUNT(x) do {} while (0) 129 129 #endif 130 + 131 + /* debug files */ 132 + #ifdef DEBUG 133 + struct dentry *debug_dir; 134 + struct dentry *debug_async; 135 + struct dentry *debug_periodic; 136 + struct dentry *debug_registers; 137 + #endif 130 138 }; 131 139 132 140 /* convert between an HCD pointer and the corresponding EHCI_HCD */ ··· 148 140 } 149 141 150 142 143 + static inline void 144 + iaa_watchdog_start(struct ehci_hcd *ehci) 145 + { 146 + WARN_ON(timer_pending(&ehci->iaa_watchdog)); 147 + mod_timer(&ehci->iaa_watchdog, 148 + jiffies + msecs_to_jiffies(EHCI_IAA_MSECS)); 149 + } 150 + 151 + static inline void iaa_watchdog_done(struct ehci_hcd *ehci) 152 + { 153 + del_timer(&ehci->iaa_watchdog); 154 + } 155 + 151 156 enum ehci_timer_action { 152 157 TIMER_IO_WATCHDOG, 153 - TIMER_IAA_WATCHDOG, 154 158 TIMER_ASYNC_SHRINK, 155 159 TIMER_ASYNC_OFF, 156 160 }; ··· 180 160 unsigned long t; 181 161 182 162 switch (action) { 183 - case TIMER_IAA_WATCHDOG: 184 - t = EHCI_IAA_JIFFIES; 185 - break; 186 163 case TIMER_IO_WATCHDOG: 187 164 t = EHCI_IO_JIFFIES; 188 165 break; ··· 196 179 // async queue SHRINK often precedes IAA. while it's ready 197 180 // to go OFF neither can matter, and afterwards the IO 198 181 // watchdog stops unless there's still periodic traffic. 199 - if (action != TIMER_IAA_WATCHDOG 200 - && t > ehci->watchdog.expires 182 + if (time_before_eq(t, ehci->watchdog.expires) 201 183 && timer_pending (&ehci->watchdog)) 202 184 return; 203 185 mod_timer (&ehci->watchdog, t); ··· 550 534 * trusting urb->interval == f(epdesc->bInterval) and 551 535 * including the extra info for hw_bufp[0..2] 552 536 */ 553 - u8 interval; 554 537 u8 usecs, c_usecs; 538 + u16 interval; 555 539 u16 tt_usecs; 556 540 u16 maxp; 557 541 u16 raw_mask; ··· 602 586 unsigned frame; /* where scheduled */ 603 587 unsigned pg; 604 588 unsigned index[8]; /* in urb->iso_frame_desc */ 605 - u8 usecs[8]; 606 589 } __attribute__ ((aligned (32))); 607 590 608 591 /*-------------------------------------------------------------------------*/ ··· 740 725 * definition below can die once the 4xx support is 741 726 * finally ported over. 742 727 */ 743 - #if defined(CONFIG_PPC) 728 + #if defined(CONFIG_PPC) && !defined(CONFIG_PPC_MERGE) 744 729 #define readl_be(addr) in_be32((__force unsigned *)addr) 745 730 #define writel_be(val, addr) out_be32((__force unsigned *)addr, val) 731 + #endif 732 + 733 + #if defined(CONFIG_ARM) && defined(CONFIG_ARCH_IXP4XX) 734 + #define readl_be(addr) __raw_readl((__force unsigned *)addr) 735 + #define writel_be(val, addr) __raw_writel(val, (__force unsigned *)addr) 746 736 #endif 747 737 748 738 static inline unsigned int ehci_readl(const struct ehci_hcd *ehci,
-1
drivers/usb/host/isp116x-hcd.c
··· 918 918 | RH_PS_OCIC | RH_PS_PRSC)) { 919 919 changed = 1; 920 920 buf[0] |= 1 << (i + 1); 921 - continue; 922 921 } 923 922 } 924 923 spin_unlock_irqrestore(&isp116x->lock, flags);
+31
drivers/usb/host/ohci-at91.c
··· 17 17 18 18 #include <asm/mach-types.h> 19 19 #include <asm/hardware.h> 20 + #include <asm/gpio.h> 21 + 20 22 #include <asm/arch/board.h> 21 23 #include <asm/arch/cpu.h> 22 24 ··· 273 271 274 272 static int ohci_hcd_at91_drv_probe(struct platform_device *pdev) 275 273 { 274 + struct at91_usbh_data *pdata = pdev->dev.platform_data; 275 + int i; 276 + 277 + if (pdata) { 278 + /* REVISIT make the driver support per-port power switching, 279 + * and also overcurrent detection. Here we assume the ports 280 + * are always powered while this driver is active, and use 281 + * active-low power switches. 282 + */ 283 + for (i = 0; i < pdata->ports; i++) { 284 + if (pdata->vbus_pin[i] <= 0) 285 + continue; 286 + gpio_request(pdata->vbus_pin[i], "ohci_vbus"); 287 + gpio_direction_output(pdata->vbus_pin[i], 0); 288 + } 289 + } 290 + 276 291 device_init_wakeup(&pdev->dev, 1); 277 292 return usb_hcd_at91_probe(&ohci_at91_hc_driver, pdev); 278 293 } 279 294 280 295 static int ohci_hcd_at91_drv_remove(struct platform_device *pdev) 281 296 { 297 + struct at91_usbh_data *pdata = pdev->dev.platform_data; 298 + int i; 299 + 300 + if (pdata) { 301 + for (i = 0; i < pdata->ports; i++) { 302 + if (pdata->vbus_pin[i] <= 0) 303 + continue; 304 + gpio_direction_output(pdata->vbus_pin[i], 1); 305 + gpio_free(pdata->vbus_pin[i]); 306 + } 307 + } 308 + 282 309 device_init_wakeup(&pdev->dev, 0); 283 310 return usb_hcd_at91_remove(platform_get_drvdata(pdev), pdev); 284 311 }
+184 -29
drivers/usb/host/ohci-dbg.c
··· 401 401 402 402 #else 403 403 404 + static int debug_async_open(struct inode *, struct file *); 405 + static int debug_periodic_open(struct inode *, struct file *); 406 + static int debug_registers_open(struct inode *, struct file *); 407 + static int debug_async_open(struct inode *, struct file *); 408 + static ssize_t debug_output(struct file*, char __user*, size_t, loff_t*); 409 + static int debug_close(struct inode *, struct file *); 410 + 411 + static const struct file_operations debug_async_fops = { 412 + .owner = THIS_MODULE, 413 + .open = debug_async_open, 414 + .read = debug_output, 415 + .release = debug_close, 416 + }; 417 + static const struct file_operations debug_periodic_fops = { 418 + .owner = THIS_MODULE, 419 + .open = debug_periodic_open, 420 + .read = debug_output, 421 + .release = debug_close, 422 + }; 423 + static const struct file_operations debug_registers_fops = { 424 + .owner = THIS_MODULE, 425 + .open = debug_registers_open, 426 + .read = debug_output, 427 + .release = debug_close, 428 + }; 429 + 430 + static struct dentry *ohci_debug_root; 431 + 432 + struct debug_buffer { 433 + ssize_t (*fill_func)(struct debug_buffer *); /* fill method */ 434 + struct device *dev; 435 + struct mutex mutex; /* protect filling of buffer */ 436 + size_t count; /* number of characters filled into buffer */ 437 + char *page; 438 + }; 439 + 404 440 static ssize_t 405 441 show_list (struct ohci_hcd *ohci, char *buf, size_t count, struct ed *ed) 406 442 { ··· 503 467 return count - size; 504 468 } 505 469 506 - static ssize_t 507 - show_async (struct class_device *class_dev, char *buf) 470 + static ssize_t fill_async_buffer(struct debug_buffer *buf) 508 471 { 509 472 struct usb_bus *bus; 510 473 struct usb_hcd *hcd; ··· 511 476 size_t temp; 512 477 unsigned long flags; 513 478 514 - bus = class_get_devdata(class_dev); 479 + bus = dev_get_drvdata(buf->dev); 515 480 hcd = bus_to_hcd(bus); 516 481 ohci = hcd_to_ohci(hcd); 517 482 518 483 /* display control and bulk lists together, for simplicity */ 519 484 spin_lock_irqsave (&ohci->lock, flags); 520 - temp = show_list (ohci, buf, PAGE_SIZE, ohci->ed_controltail); 521 - temp += show_list (ohci, buf + temp, PAGE_SIZE - temp, ohci->ed_bulktail); 485 + temp = show_list(ohci, buf->page, buf->count, ohci->ed_controltail); 486 + temp += show_list(ohci, buf->page + temp, buf->count - temp, 487 + ohci->ed_bulktail); 522 488 spin_unlock_irqrestore (&ohci->lock, flags); 523 489 524 490 return temp; 525 491 } 526 - static CLASS_DEVICE_ATTR (async, S_IRUGO, show_async, NULL); 527 - 528 492 529 493 #define DBG_SCHED_LIMIT 64 530 494 531 - static ssize_t 532 - show_periodic (struct class_device *class_dev, char *buf) 495 + static ssize_t fill_periodic_buffer(struct debug_buffer *buf) 533 496 { 534 497 struct usb_bus *bus; 535 498 struct usb_hcd *hcd; ··· 542 509 return 0; 543 510 seen_count = 0; 544 511 545 - bus = class_get_devdata(class_dev); 512 + bus = (struct usb_bus *)dev_get_drvdata(buf->dev); 546 513 hcd = bus_to_hcd(bus); 547 514 ohci = hcd_to_ohci(hcd); 548 - next = buf; 515 + next = buf->page; 549 516 size = PAGE_SIZE; 550 517 551 518 temp = scnprintf (next, size, "size = %d\n", NUM_INTS); ··· 622 589 623 590 return PAGE_SIZE - size; 624 591 } 625 - static CLASS_DEVICE_ATTR (periodic, S_IRUGO, show_periodic, NULL); 626 - 627 - 628 592 #undef DBG_SCHED_LIMIT 629 593 630 - static ssize_t 631 - show_registers (struct class_device *class_dev, char *buf) 594 + static ssize_t fill_registers_buffer(struct debug_buffer *buf) 632 595 { 633 596 struct usb_bus *bus; 634 597 struct usb_hcd *hcd; ··· 635 606 char *next; 636 607 u32 rdata; 637 608 638 - bus = class_get_devdata(class_dev); 609 + bus = (struct usb_bus *)dev_get_drvdata(buf->dev); 639 610 hcd = bus_to_hcd(bus); 640 611 ohci = hcd_to_ohci(hcd); 641 612 regs = ohci->regs; 642 - next = buf; 613 + next = buf->page; 643 614 size = PAGE_SIZE; 644 615 645 616 spin_lock_irqsave (&ohci->lock, flags); ··· 706 677 707 678 done: 708 679 spin_unlock_irqrestore (&ohci->lock, flags); 680 + 709 681 return PAGE_SIZE - size; 710 682 } 711 - static CLASS_DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL); 712 683 684 + static struct debug_buffer *alloc_buffer(struct device *dev, 685 + ssize_t (*fill_func)(struct debug_buffer *)) 686 + { 687 + struct debug_buffer *buf; 713 688 689 + buf = kzalloc(sizeof(struct debug_buffer), GFP_KERNEL); 690 + 691 + if (buf) { 692 + buf->dev = dev; 693 + buf->fill_func = fill_func; 694 + mutex_init(&buf->mutex); 695 + } 696 + 697 + return buf; 698 + } 699 + 700 + static int fill_buffer(struct debug_buffer *buf) 701 + { 702 + int ret = 0; 703 + 704 + if (!buf->page) 705 + buf->page = (char *)get_zeroed_page(GFP_KERNEL); 706 + 707 + if (!buf->page) { 708 + ret = -ENOMEM; 709 + goto out; 710 + } 711 + 712 + ret = buf->fill_func(buf); 713 + 714 + if (ret >= 0) { 715 + buf->count = ret; 716 + ret = 0; 717 + } 718 + 719 + out: 720 + return ret; 721 + } 722 + 723 + static ssize_t debug_output(struct file *file, char __user *user_buf, 724 + size_t len, loff_t *offset) 725 + { 726 + struct debug_buffer *buf = file->private_data; 727 + int ret = 0; 728 + 729 + mutex_lock(&buf->mutex); 730 + if (buf->count == 0) { 731 + ret = fill_buffer(buf); 732 + if (ret != 0) { 733 + mutex_unlock(&buf->mutex); 734 + goto out; 735 + } 736 + } 737 + mutex_unlock(&buf->mutex); 738 + 739 + ret = simple_read_from_buffer(user_buf, len, offset, 740 + buf->page, buf->count); 741 + 742 + out: 743 + return ret; 744 + 745 + } 746 + 747 + static int debug_close(struct inode *inode, struct file *file) 748 + { 749 + struct debug_buffer *buf = file->private_data; 750 + 751 + if (buf) { 752 + if (buf->page) 753 + free_page((unsigned long)buf->page); 754 + kfree(buf); 755 + } 756 + 757 + return 0; 758 + } 759 + static int debug_async_open(struct inode *inode, struct file *file) 760 + { 761 + file->private_data = alloc_buffer(inode->i_private, fill_async_buffer); 762 + 763 + return file->private_data ? 0 : -ENOMEM; 764 + } 765 + 766 + static int debug_periodic_open(struct inode *inode, struct file *file) 767 + { 768 + file->private_data = alloc_buffer(inode->i_private, 769 + fill_periodic_buffer); 770 + 771 + return file->private_data ? 0 : -ENOMEM; 772 + } 773 + 774 + static int debug_registers_open(struct inode *inode, struct file *file) 775 + { 776 + file->private_data = alloc_buffer(inode->i_private, 777 + fill_registers_buffer); 778 + 779 + return file->private_data ? 0 : -ENOMEM; 780 + } 714 781 static inline void create_debug_files (struct ohci_hcd *ohci) 715 782 { 716 - struct class_device *cldev = ohci_to_hcd(ohci)->self.class_dev; 717 - int retval; 783 + struct usb_bus *bus = &ohci_to_hcd(ohci)->self; 784 + struct device *dev = bus->dev; 718 785 719 - retval = class_device_create_file(cldev, &class_device_attr_async); 720 - retval = class_device_create_file(cldev, &class_device_attr_periodic); 721 - retval = class_device_create_file(cldev, &class_device_attr_registers); 786 + ohci->debug_dir = debugfs_create_dir(bus->bus_name, ohci_debug_root); 787 + if (!ohci->debug_dir) 788 + goto dir_error; 789 + 790 + ohci->debug_async = debugfs_create_file("async", S_IRUGO, 791 + ohci->debug_dir, dev, 792 + &debug_async_fops); 793 + if (!ohci->debug_async) 794 + goto async_error; 795 + 796 + ohci->debug_periodic = debugfs_create_file("periodic", S_IRUGO, 797 + ohci->debug_dir, dev, 798 + &debug_periodic_fops); 799 + if (!ohci->debug_periodic) 800 + goto periodic_error; 801 + 802 + ohci->debug_registers = debugfs_create_file("registers", S_IRUGO, 803 + ohci->debug_dir, dev, 804 + &debug_registers_fops); 805 + if (!ohci->debug_registers) 806 + goto registers_error; 807 + 722 808 ohci_dbg (ohci, "created debug files\n"); 809 + return; 810 + 811 + registers_error: 812 + debugfs_remove(ohci->debug_periodic); 813 + periodic_error: 814 + debugfs_remove(ohci->debug_async); 815 + async_error: 816 + debugfs_remove(ohci->debug_dir); 817 + dir_error: 818 + ohci->debug_periodic = NULL; 819 + ohci->debug_async = NULL; 820 + ohci->debug_dir = NULL; 723 821 } 724 822 725 823 static inline void remove_debug_files (struct ohci_hcd *ohci) 726 824 { 727 - struct class_device *cldev = ohci_to_hcd(ohci)->self.class_dev; 728 - 729 - class_device_remove_file(cldev, &class_device_attr_async); 730 - class_device_remove_file(cldev, &class_device_attr_periodic); 731 - class_device_remove_file(cldev, &class_device_attr_registers); 825 + debugfs_remove(ohci->debug_registers); 826 + debugfs_remove(ohci->debug_periodic); 827 + debugfs_remove(ohci->debug_async); 828 + debugfs_remove(ohci->debug_dir); 732 829 } 733 830 734 831 #endif
+30 -4
drivers/usb/host/ohci-hcd.c
··· 36 36 #include <linux/dmapool.h> 37 37 #include <linux/reboot.h> 38 38 #include <linux/workqueue.h> 39 + #include <linux/debugfs.h> 39 40 40 41 #include <asm/io.h> 41 42 #include <asm/irq.h> ··· 810 809 } 811 810 812 811 if (ints & OHCI_INTR_WDH) { 813 - if (HC_IS_RUNNING(hcd->state)) 814 - ohci_writel (ohci, OHCI_INTR_WDH, &regs->intrdisable); 815 812 spin_lock (&ohci->lock); 816 813 dl_done_list (ohci); 817 814 spin_unlock (&ohci->lock); 818 - if (HC_IS_RUNNING(hcd->state)) 819 - ohci_writel (ohci, OHCI_INTR_WDH, &regs->intrenable); 820 815 } 821 816 822 817 if (quirk_zfmicro(ohci) && (ints & OHCI_INTR_SF)) { ··· 1029 1032 #define PLATFORM_DRIVER usb_hcd_pnx4008_driver 1030 1033 #endif 1031 1034 1035 + #if defined(CONFIG_CPU_SUBTYPE_SH7720) || \ 1036 + defined(CONFIG_CPU_SUBTYPE_SH7721) || \ 1037 + defined(CONFIG_CPU_SUBTYPE_SH7763) 1038 + #include "ohci-sh.c" 1039 + #define PLATFORM_DRIVER ohci_hcd_sh_driver 1040 + #endif 1041 + 1032 1042 1033 1043 #ifdef CONFIG_USB_OHCI_HCD_PPC_OF 1034 1044 #include "ohci-ppc-of.c" ··· 1050 1046 #ifdef CONFIG_USB_OHCI_HCD_SSB 1051 1047 #include "ohci-ssb.c" 1052 1048 #define SSB_OHCI_DRIVER ssb_ohci_driver 1049 + #endif 1050 + 1051 + #ifdef CONFIG_MFD_SM501 1052 + #include "ohci-sm501.c" 1053 + #define PLATFORM_DRIVER ohci_hcd_sm501_driver 1053 1054 #endif 1054 1055 1055 1056 #if !defined(PCI_DRIVER) && \ ··· 1076 1067 printk (KERN_DEBUG "%s: " DRIVER_INFO "\n", hcd_name); 1077 1068 pr_debug ("%s: block sizes: ed %Zd td %Zd\n", hcd_name, 1078 1069 sizeof (struct ed), sizeof (struct td)); 1070 + 1071 + #ifdef DEBUG 1072 + ohci_debug_root = debugfs_create_dir("ohci", NULL); 1073 + if (!ohci_debug_root) { 1074 + retval = -ENOENT; 1075 + goto error_debug; 1076 + } 1077 + #endif 1079 1078 1080 1079 #ifdef PS3_SYSTEM_BUS_DRIVER 1081 1080 retval = ps3_ohci_driver_register(&PS3_SYSTEM_BUS_DRIVER); ··· 1147 1130 ps3_ohci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); 1148 1131 error_ps3: 1149 1132 #endif 1133 + #ifdef DEBUG 1134 + debugfs_remove(ohci_debug_root); 1135 + ohci_debug_root = NULL; 1136 + error_debug: 1137 + #endif 1138 + 1150 1139 return retval; 1151 1140 } 1152 1141 module_init(ohci_hcd_mod_init); ··· 1176 1153 #endif 1177 1154 #ifdef PS3_SYSTEM_BUS_DRIVER 1178 1155 ps3_ohci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); 1156 + #endif 1157 + #ifdef DEBUG 1158 + debugfs_remove(ohci_debug_root); 1179 1159 #endif 1180 1160 } 1181 1161 module_exit(ohci_hcd_mod_exit);
+143
drivers/usb/host/ohci-sh.c
··· 1 + /* 2 + * OHCI HCD (Host Controller Driver) for USB. 3 + * 4 + * Copyright (C) 2008 Renesas Solutions Corp. 5 + * 6 + * Author : Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com> 7 + * 8 + * This program is free software; you can redistribute it and/or modify 9 + * it under the terms of the GNU General Public License as published by 10 + * the Free Software Foundation; version 2 of the License. 11 + * 12 + * This program is distributed in the hope that it will be useful, 13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 + * GNU General Public License for more details. 16 + * 17 + * You should have received a copy of the GNU General Public License 18 + * along with this program; if not, write to the Free Software 19 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 + * 21 + */ 22 + 23 + #include <linux/platform_device.h> 24 + 25 + static int ohci_sh_start(struct usb_hcd *hcd) 26 + { 27 + struct ohci_hcd *ohci = hcd_to_ohci(hcd); 28 + 29 + ohci_hcd_init(ohci); 30 + ohci_init(ohci); 31 + ohci_run(ohci); 32 + hcd->state = HC_STATE_RUNNING; 33 + return 0; 34 + } 35 + 36 + static const struct hc_driver ohci_sh_hc_driver = { 37 + .description = hcd_name, 38 + .product_desc = "SuperH OHCI", 39 + .hcd_priv_size = sizeof(struct ohci_hcd), 40 + 41 + /* 42 + * generic hardware linkage 43 + */ 44 + .irq = ohci_irq, 45 + .flags = HCD_USB11 | HCD_MEMORY, 46 + 47 + /* 48 + * basic lifecycle operations 49 + */ 50 + .start = ohci_sh_start, 51 + .stop = ohci_stop, 52 + .shutdown = ohci_shutdown, 53 + 54 + /* 55 + * managing i/o requests and associated device resources 56 + */ 57 + .urb_enqueue = ohci_urb_enqueue, 58 + .urb_dequeue = ohci_urb_dequeue, 59 + .endpoint_disable = ohci_endpoint_disable, 60 + 61 + /* 62 + * scheduling support 63 + */ 64 + .get_frame_number = ohci_get_frame, 65 + 66 + /* 67 + * root hub support 68 + */ 69 + .hub_status_data = ohci_hub_status_data, 70 + .hub_control = ohci_hub_control, 71 + .hub_irq_enable = ohci_rhsc_enable, 72 + #ifdef CONFIG_PM 73 + .bus_suspend = ohci_bus_suspend, 74 + .bus_resume = ohci_bus_resume, 75 + #endif 76 + .start_port_reset = ohci_start_port_reset, 77 + }; 78 + 79 + /*-------------------------------------------------------------------------*/ 80 + 81 + #define resource_len(r) (((r)->end - (r)->start) + 1) 82 + static int ohci_hcd_sh_probe(struct platform_device *pdev) 83 + { 84 + struct resource *res = NULL; 85 + struct usb_hcd *hcd = NULL; 86 + int irq = -1; 87 + int ret; 88 + 89 + if (usb_disabled()) 90 + return -ENODEV; 91 + 92 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 93 + if (!res) { 94 + err("platform_get_resource error."); 95 + return -ENODEV; 96 + } 97 + 98 + irq = platform_get_irq(pdev, 0); 99 + if (irq < 0) { 100 + err("platform_get_irq error."); 101 + return -ENODEV; 102 + } 103 + 104 + /* initialize hcd */ 105 + hcd = usb_create_hcd(&ohci_sh_hc_driver, &pdev->dev, (char *)hcd_name); 106 + if (!hcd) { 107 + err("Failed to create hcd"); 108 + return -ENOMEM; 109 + } 110 + 111 + hcd->regs = (void __iomem *)res->start; 112 + hcd->rsrc_start = res->start; 113 + hcd->rsrc_len = resource_len(res); 114 + ret = usb_add_hcd(hcd, irq, IRQF_DISABLED); 115 + if (ret != 0) { 116 + err("Failed to add hcd"); 117 + usb_put_hcd(hcd); 118 + return ret; 119 + } 120 + 121 + return ret; 122 + } 123 + 124 + static int ohci_hcd_sh_remove(struct platform_device *pdev) 125 + { 126 + struct usb_hcd *hcd = platform_get_drvdata(pdev); 127 + 128 + usb_remove_hcd(hcd); 129 + usb_put_hcd(hcd); 130 + 131 + return 0; 132 + } 133 + 134 + static struct platform_driver ohci_hcd_sh_driver = { 135 + .probe = ohci_hcd_sh_probe, 136 + .remove = ohci_hcd_sh_remove, 137 + .shutdown = usb_hcd_platform_shutdown, 138 + .driver = { 139 + .name = "sh_ohci", 140 + .owner = THIS_MODULE, 141 + }, 142 + }; 143 +
+264
drivers/usb/host/ohci-sm501.c
··· 1 + /* 2 + * OHCI HCD (Host Controller Driver) for USB. 3 + * 4 + * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at> 5 + * (C) Copyright 2000-2005 David Brownell 6 + * (C) Copyright 2002 Hewlett-Packard Company 7 + * (C) Copyright 2008 Magnus Damm 8 + * 9 + * SM501 Bus Glue - based on ohci-omap.c 10 + * 11 + * This file is licenced under the GPL. 12 + */ 13 + 14 + #include <linux/interrupt.h> 15 + #include <linux/jiffies.h> 16 + #include <linux/platform_device.h> 17 + #include <linux/dma-mapping.h> 18 + #include <linux/sm501.h> 19 + #include <linux/sm501-regs.h> 20 + 21 + static int ohci_sm501_init(struct usb_hcd *hcd) 22 + { 23 + return ohci_init(hcd_to_ohci(hcd)); 24 + } 25 + 26 + static int ohci_sm501_start(struct usb_hcd *hcd) 27 + { 28 + struct device *dev = hcd->self.controller; 29 + int ret; 30 + 31 + ret = ohci_run(hcd_to_ohci(hcd)); 32 + if (ret < 0) { 33 + dev_err(dev, "can't start %s", hcd->self.bus_name); 34 + ohci_stop(hcd); 35 + } 36 + 37 + return ret; 38 + } 39 + 40 + /*-------------------------------------------------------------------------*/ 41 + 42 + static const struct hc_driver ohci_sm501_hc_driver = { 43 + .description = hcd_name, 44 + .product_desc = "SM501 OHCI", 45 + .hcd_priv_size = sizeof(struct ohci_hcd), 46 + 47 + /* 48 + * generic hardware linkage 49 + */ 50 + .irq = ohci_irq, 51 + .flags = HCD_USB11 | HCD_MEMORY | HCD_LOCAL_MEM, 52 + 53 + /* 54 + * basic lifecycle operations 55 + */ 56 + .reset = ohci_sm501_init, 57 + .start = ohci_sm501_start, 58 + .stop = ohci_stop, 59 + .shutdown = ohci_shutdown, 60 + 61 + /* 62 + * managing i/o requests and associated device resources 63 + */ 64 + .urb_enqueue = ohci_urb_enqueue, 65 + .urb_dequeue = ohci_urb_dequeue, 66 + .endpoint_disable = ohci_endpoint_disable, 67 + 68 + /* 69 + * scheduling support 70 + */ 71 + .get_frame_number = ohci_get_frame, 72 + 73 + /* 74 + * root hub support 75 + */ 76 + .hub_status_data = ohci_hub_status_data, 77 + .hub_control = ohci_hub_control, 78 + .hub_irq_enable = ohci_rhsc_enable, 79 + #ifdef CONFIG_PM 80 + .bus_suspend = ohci_bus_suspend, 81 + .bus_resume = ohci_bus_resume, 82 + #endif 83 + .start_port_reset = ohci_start_port_reset, 84 + }; 85 + 86 + /*-------------------------------------------------------------------------*/ 87 + 88 + static int ohci_hcd_sm501_drv_probe(struct platform_device *pdev) 89 + { 90 + const struct hc_driver *driver = &ohci_sm501_hc_driver; 91 + struct device *dev = &pdev->dev; 92 + struct resource *res, *mem; 93 + int retval, irq; 94 + struct usb_hcd *hcd = 0; 95 + 96 + irq = retval = platform_get_irq(pdev, 0); 97 + if (retval < 0) 98 + goto err0; 99 + 100 + mem = platform_get_resource(pdev, IORESOURCE_MEM, 1); 101 + if (mem == NULL) { 102 + dev_err(dev, "no resource definition for memory\n"); 103 + retval = -ENOENT; 104 + goto err0; 105 + } 106 + 107 + if (!request_mem_region(mem->start, mem->end - mem->start + 1, 108 + pdev->name)) { 109 + dev_err(dev, "request_mem_region failed\n"); 110 + retval = -EBUSY; 111 + goto err0; 112 + } 113 + 114 + /* The sm501 chip is equipped with local memory that may be used 115 + * by on-chip devices such as the video controller and the usb host. 116 + * This driver uses dma_declare_coherent_memory() to make sure 117 + * usb allocations with dma_alloc_coherent() allocate from 118 + * this local memory. The dma_handle returned by dma_alloc_coherent() 119 + * will be an offset starting from 0 for the first local memory byte. 120 + * 121 + * So as long as data is allocated using dma_alloc_coherent() all is 122 + * fine. This is however not always the case - buffers may be allocated 123 + * using kmalloc() - so the usb core needs to be told that it must copy 124 + * data into our local memory if the buffers happen to be placed in 125 + * regular memory. The HCD_LOCAL_MEM flag does just that. 126 + */ 127 + 128 + if (!dma_declare_coherent_memory(dev, mem->start, 129 + mem->start - mem->parent->start, 130 + (mem->end - mem->start) + 1, 131 + DMA_MEMORY_MAP | 132 + DMA_MEMORY_EXCLUSIVE)) { 133 + dev_err(dev, "cannot declare coherent memory\n"); 134 + retval = -ENXIO; 135 + goto err1; 136 + } 137 + 138 + /* allocate, reserve and remap resources for registers */ 139 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 140 + if (res == NULL) { 141 + dev_err(dev, "no resource definition for registers\n"); 142 + retval = -ENOENT; 143 + goto err2; 144 + } 145 + 146 + hcd = usb_create_hcd(driver, &pdev->dev, pdev->dev.bus_id); 147 + if (!hcd) { 148 + retval = -ENOMEM; 149 + goto err2; 150 + } 151 + 152 + hcd->rsrc_start = res->start; 153 + hcd->rsrc_len = res->end - res->start + 1; 154 + 155 + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, pdev->name)) { 156 + dev_err(dev, "request_mem_region failed\n"); 157 + retval = -EBUSY; 158 + goto err3; 159 + } 160 + 161 + hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); 162 + if (hcd->regs == NULL) { 163 + dev_err(dev, "cannot remap registers\n"); 164 + retval = -ENXIO; 165 + goto err4; 166 + } 167 + 168 + ohci_hcd_init(hcd_to_ohci(hcd)); 169 + 170 + retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED); 171 + if (retval) 172 + goto err4; 173 + 174 + /* enable power and unmask interrupts */ 175 + 176 + sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 1); 177 + sm501_modify_reg(dev->parent, SM501_IRQ_MASK, 1 << 6, 0); 178 + 179 + return 0; 180 + err4: 181 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 182 + err3: 183 + usb_put_hcd(hcd); 184 + err2: 185 + dma_release_declared_memory(dev); 186 + err1: 187 + release_mem_region(mem->start, mem->end - mem->start + 1); 188 + err0: 189 + return retval; 190 + } 191 + 192 + static int ohci_hcd_sm501_drv_remove(struct platform_device *pdev) 193 + { 194 + struct usb_hcd *hcd = platform_get_drvdata(pdev); 195 + struct resource *mem; 196 + 197 + usb_remove_hcd(hcd); 198 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 199 + usb_put_hcd(hcd); 200 + dma_release_declared_memory(&pdev->dev); 201 + mem = platform_get_resource(pdev, IORESOURCE_MEM, 1); 202 + release_mem_region(mem->start, mem->end - mem->start + 1); 203 + 204 + /* mask interrupts and disable power */ 205 + 206 + sm501_modify_reg(pdev->dev.parent, SM501_IRQ_MASK, 0, 1 << 6); 207 + sm501_unit_power(pdev->dev.parent, SM501_GATE_USB_HOST, 0); 208 + 209 + platform_set_drvdata(pdev, NULL); 210 + return 0; 211 + } 212 + 213 + /*-------------------------------------------------------------------------*/ 214 + 215 + #ifdef CONFIG_PM 216 + static int ohci_sm501_suspend(struct platform_device *pdev, pm_message_t msg) 217 + { 218 + struct device *dev = &pdev->dev; 219 + struct ohci_hcd *ohci = hcd_to_ohci(platform_get_drvdata(pdev)); 220 + 221 + if (time_before(jiffies, ohci->next_statechange)) 222 + msleep(5); 223 + ohci->next_statechange = jiffies; 224 + 225 + sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 0); 226 + ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED; 227 + dev->power.power_state = PMSG_SUSPEND; 228 + return 0; 229 + } 230 + 231 + static int ohci_sm501_resume(struct platform_device *pdev) 232 + { 233 + struct device *dev = &pdev->dev; 234 + struct ohci_hcd *ohci = hcd_to_ohci(platform_get_drvdata(pdev)); 235 + 236 + if (time_before(jiffies, ohci->next_statechange)) 237 + msleep(5); 238 + ohci->next_statechange = jiffies; 239 + 240 + sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 1); 241 + dev->power.power_state = PMSG_ON; 242 + usb_hcd_resume_root_hub(platform_get_drvdata(pdev)); 243 + return 0; 244 + } 245 + #endif 246 + 247 + /*-------------------------------------------------------------------------*/ 248 + 249 + /* 250 + * Driver definition to register with the SM501 bus 251 + */ 252 + static struct platform_driver ohci_hcd_sm501_driver = { 253 + .probe = ohci_hcd_sm501_drv_probe, 254 + .remove = ohci_hcd_sm501_drv_remove, 255 + .shutdown = usb_hcd_platform_shutdown, 256 + #ifdef CONFIG_PM 257 + .suspend = ohci_sm501_suspend, 258 + .resume = ohci_sm501_resume, 259 + #endif 260 + .driver = { 261 + .owner = THIS_MODULE, 262 + .name = "sm501-usb", 263 + }, 264 + };
+7
drivers/usb/host/ohci.h
··· 408 408 unsigned eds_scheduled; 409 409 struct ed *ed_to_check; 410 410 unsigned zf_delay; 411 + 412 + #ifdef DEBUG 413 + struct dentry *debug_dir; 414 + struct dentry *debug_async; 415 + struct dentry *debug_periodic; 416 + struct dentry *debug_registers; 417 + #endif 411 418 }; 412 419 413 420 #ifdef CONFIG_PCI
+1 -1
drivers/usb/host/r8a66597.h
··· 405 405 406 406 struct r8a66597_pipe_info { 407 407 u16 pipenum; 408 - u16 address; /* R8A66597 HCD usb addres */ 408 + u16 address; /* R8A66597 HCD usb address */ 409 409 u16 epnum; 410 410 u16 maxpacket; 411 411 u16 type;
-2
drivers/usb/image/mdc800.c
··· 478 478 { 479 479 irq_interval=intf_desc->endpoint [j].desc.bInterval; 480 480 } 481 - 482 - continue; 483 481 } 484 482 } 485 483 if (mdc800->endpoint[i] == -1)
+5 -2
drivers/usb/misc/cypress_cy7c63.c
··· 1 1 /* 2 2 * cypress_cy7c63.c 3 3 * 4 - * Copyright (c) 2006 Oliver Bock (o.bock@fh-wolfenbuettel.de) 4 + * Copyright (c) 2006-2007 Oliver Bock (bock@tfh-berlin.de) 5 5 * 6 6 * This driver is based on the Cypress USB Driver by Marcus Maul 7 7 * (cyport) and the 2.0 version of Greg Kroah-Hartman's ··· 21 21 * Supported functions: Read/Write Ports 22 22 * 23 23 * 24 + * For up-to-date information please visit: 25 + * http://www.obock.de/kernel/cypress 26 + * 24 27 * This program is free software; you can redistribute it and/or 25 28 * modify it under the terms of the GNU General Public License as 26 29 * published by the Free Software Foundation, version 2. ··· 34 31 #include <linux/kernel.h> 35 32 #include <linux/usb.h> 36 33 37 - #define DRIVER_AUTHOR "Oliver Bock (o.bock@fh-wolfenbuettel.de)" 34 + #define DRIVER_AUTHOR "Oliver Bock (bock@tfh-berlin.de)" 38 35 #define DRIVER_DESC "Cypress CY7C63xxx USB driver" 39 36 40 37 #define CYPRESS_VENDOR_ID 0xa2c
+1 -1
drivers/usb/misc/iowarrior.c
··· 715 715 * would use "struct net_driver" instead, and a serial 716 716 * device would use "struct tty_driver". 717 717 */ 718 - static struct file_operations iowarrior_fops = { 718 + static const struct file_operations iowarrior_fops = { 719 719 .owner = THIS_MODULE, 720 720 .write = iowarrior_write, 721 721 .read = iowarrior_read,
+16 -14
drivers/usb/misc/legousbtower.c
··· 205 205 206 206 /* Structure to hold all of our device specific stuff */ 207 207 struct lego_usb_tower { 208 - struct semaphore sem; /* locks this structure */ 208 + struct mutex lock; /* locks this structure */ 209 209 struct usb_device* udev; /* save off the usb device pointer */ 210 210 unsigned char minor; /* the starting minor number for this device */ 211 211 ··· 361 361 } 362 362 363 363 /* lock this device */ 364 - if (down_interruptible (&dev->sem)) { 364 + if (mutex_lock_interruptible(&dev->lock)) { 365 365 mutex_unlock(&open_disc_mutex); 366 366 retval = -ERESTARTSYS; 367 367 goto exit; ··· 421 421 file->private_data = dev; 422 422 423 423 unlock_exit: 424 - up (&dev->sem); 424 + mutex_unlock(&dev->lock); 425 425 426 426 exit: 427 427 dbg(2, "%s: leave, return value %d ", __FUNCTION__, retval); ··· 448 448 } 449 449 450 450 mutex_lock(&open_disc_mutex); 451 - if (down_interruptible (&dev->sem)) { 451 + if (mutex_lock_interruptible(&dev->lock)) { 452 452 retval = -ERESTARTSYS; 453 453 goto exit; 454 454 } ··· 460 460 } 461 461 if (dev->udev == NULL) { 462 462 /* the device was unplugged before the file was released */ 463 - up (&dev->sem); /* unlock here as tower_delete frees dev */ 463 + 464 + /* unlock here as tower_delete frees dev */ 465 + mutex_unlock(&dev->lock); 464 466 tower_delete (dev); 465 467 goto exit; 466 468 } ··· 475 473 dev->open_count = 0; 476 474 477 475 unlock_exit: 478 - up (&dev->sem); 476 + mutex_unlock(&dev->lock); 479 477 480 478 exit: 481 479 mutex_unlock(&open_disc_mutex); ··· 588 586 dev = (struct lego_usb_tower *)file->private_data; 589 587 590 588 /* lock this object */ 591 - if (down_interruptible (&dev->sem)) { 589 + if (mutex_lock_interruptible(&dev->lock)) { 592 590 retval = -ERESTARTSYS; 593 591 goto exit; 594 592 } ··· 655 653 656 654 unlock_exit: 657 655 /* unlock the device */ 658 - up (&dev->sem); 656 + mutex_unlock(&dev->lock); 659 657 660 658 exit: 661 659 dbg(2, "%s: leave, return value %d", __FUNCTION__, retval); ··· 677 675 dev = (struct lego_usb_tower *)file->private_data; 678 676 679 677 /* lock this object */ 680 - if (down_interruptible (&dev->sem)) { 678 + if (mutex_lock_interruptible(&dev->lock)) { 681 679 retval = -ERESTARTSYS; 682 680 goto exit; 683 681 } ··· 739 737 740 738 unlock_exit: 741 739 /* unlock the device */ 742 - up (&dev->sem); 740 + mutex_unlock(&dev->lock); 743 741 744 742 exit: 745 743 dbg(2, "%s: leave, return value %d", __FUNCTION__, retval); ··· 864 862 goto exit; 865 863 } 866 864 867 - init_MUTEX (&dev->sem); 865 + mutex_init(&dev->lock); 868 866 869 867 dev->udev = udev; 870 868 dev->open_count = 0; ··· 1009 1007 /* give back our minor */ 1010 1008 usb_deregister_dev (interface, &tower_class); 1011 1009 1012 - down (&dev->sem); 1010 + mutex_lock(&dev->lock); 1013 1011 mutex_unlock(&open_disc_mutex); 1014 1012 1015 1013 /* if the device is not opened, then we clean up right now */ 1016 1014 if (!dev->open_count) { 1017 - up (&dev->sem); 1015 + mutex_unlock(&dev->lock); 1018 1016 tower_delete (dev); 1019 1017 } else { 1020 1018 dev->udev = NULL; 1021 - up (&dev->sem); 1019 + mutex_unlock(&dev->lock); 1022 1020 } 1023 1021 1024 1022 info("LEGO USB Tower #%d now disconnected", (minor - LEGO_USB_TOWER_MINOR_BASE));
+1 -28
drivers/usb/misc/sisusbvga/sisusb.c
··· 323 323 usb_kill_urb(urb); 324 324 retval = -ETIMEDOUT; 325 325 } else { 326 - /* URB completed within timout */ 326 + /* URB completed within timeout */ 327 327 retval = urb->status; 328 328 readbytes = urb->actual_length; 329 329 } ··· 3195 3195 3196 3196 sisusb->present = 1; 3197 3197 3198 - #ifdef SISUSB_OLD_CONFIG_COMPAT 3199 - { 3200 - int ret; 3201 - /* Our ioctls are all "32/64bit compatible" */ 3202 - ret = register_ioctl32_conversion(SISUSB_GET_CONFIG_SIZE, NULL); 3203 - ret |= register_ioctl32_conversion(SISUSB_GET_CONFIG, NULL); 3204 - ret |= register_ioctl32_conversion(SISUSB_COMMAND, NULL); 3205 - if (ret) 3206 - dev_err(&sisusb->sisusb_dev->dev, "Error registering ioctl32 translations\n"); 3207 - else 3208 - sisusb->ioctl32registered = 1; 3209 - } 3210 - #endif 3211 - 3212 3198 if (dev->speed == USB_SPEED_HIGH) { 3213 3199 int initscreen = 1; 3214 3200 #ifdef INCL_SISUSB_CON ··· 3256 3270 sisusb_kill_all_busy(sisusb); 3257 3271 3258 3272 usb_set_intfdata(intf, NULL); 3259 - 3260 - #ifdef SISUSB_OLD_CONFIG_COMPAT 3261 - if (sisusb->ioctl32registered) { 3262 - int ret; 3263 - sisusb->ioctl32registered = 0; 3264 - ret = unregister_ioctl32_conversion(SISUSB_GET_CONFIG_SIZE); 3265 - ret |= unregister_ioctl32_conversion(SISUSB_GET_CONFIG); 3266 - ret |= unregister_ioctl32_conversion(SISUSB_COMMAND); 3267 - if (ret) { 3268 - dev_err(&sisusb->sisusb_dev->dev, "Error unregistering ioctl32 translations\n"); 3269 - } 3270 - } 3271 - #endif 3272 3273 3273 3274 sisusb->present = 0; 3274 3275 sisusb->ready = 0;
-3
drivers/usb/misc/sisusbvga/sisusb.h
··· 120 120 int isopen; /* !=0 if open */ 121 121 int present; /* !=0 if device is present on the bus */ 122 122 int ready; /* !=0 if device is ready for userland */ 123 - #ifdef SISUSB_OLD_CONFIG_COMPAT 124 - int ioctl32registered; 125 - #endif 126 123 int numobufs; /* number of obufs = number of out urbs */ 127 124 char *obuf[NUMOBUFS], *ibuf; /* transfer buffers */ 128 125 int obufsize, ibufsize;
+10 -10
drivers/usb/misc/usbtest.c
··· 6 6 #include <linux/module.h> 7 7 #include <linux/moduleparam.h> 8 8 #include <linux/scatterlist.h> 9 + #include <linux/mutex.h> 9 10 10 11 #include <linux/usb.h> 11 12 ··· 65 64 int in_iso_pipe; 66 65 int out_iso_pipe; 67 66 struct usb_endpoint_descriptor *iso_in, *iso_out; 68 - struct semaphore sem; 67 + struct mutex lock; 69 68 70 69 #define TBUF_SIZE 256 71 70 u8 *buf; ··· 1152 1151 dbg ("ep %02x couldn't get halt status, %d", ep, retval); 1153 1152 return retval; 1154 1153 } 1154 + le16_to_cpus(&status); 1155 1155 if (status != 1) { 1156 1156 dbg ("ep %02x bogus status: %04x != 1", ep, status); 1157 1157 return -EINVAL; ··· 1312 1310 len += vary; 1313 1311 1314 1312 /* [real world] the "zero bytes IN" case isn't really used. 1315 - * hardware can easily trip up in this wierd case, since its 1313 + * hardware can easily trip up in this weird case, since its 1316 1314 * status stage is IN, not OUT like other ep0in transfers. 1317 1315 */ 1318 1316 if (len > length) ··· 1560 1558 || param->sglen < 0 || param->vary < 0) 1561 1559 return -EINVAL; 1562 1560 1563 - if (down_interruptible (&dev->sem)) 1561 + if (mutex_lock_interruptible(&dev->lock)) 1564 1562 return -ERESTARTSYS; 1565 1563 1566 1564 if (intf->dev.power.power_state.event != PM_EVENT_ON) { 1567 - up (&dev->sem); 1565 + mutex_unlock(&dev->lock); 1568 1566 return -EHOSTUNREACH; 1569 1567 } 1570 1568 ··· 1576 1574 int res; 1577 1575 1578 1576 if (intf->altsetting->desc.bInterfaceNumber) { 1579 - up (&dev->sem); 1577 + mutex_unlock(&dev->lock); 1580 1578 return -ENODEV; 1581 1579 } 1582 1580 res = set_altsetting (dev, dev->info->alt); ··· 1584 1582 dev_err (&intf->dev, 1585 1583 "set altsetting to %d failed, %d\n", 1586 1584 dev->info->alt, res); 1587 - up (&dev->sem); 1585 + mutex_unlock(&dev->lock); 1588 1586 return res; 1589 1587 } 1590 1588 } ··· 1857 1855 param->duration.tv_usec += 1000 * 1000; 1858 1856 param->duration.tv_sec -= 1; 1859 1857 } 1860 - up (&dev->sem); 1858 + mutex_unlock(&dev->lock); 1861 1859 return retval; 1862 1860 } 1863 1861 ··· 1907 1905 return -ENOMEM; 1908 1906 info = (struct usbtest_info *) id->driver_info; 1909 1907 dev->info = info; 1910 - init_MUTEX (&dev->sem); 1908 + mutex_init(&dev->lock); 1911 1909 1912 1910 dev->intf = intf; 1913 1911 ··· 1991 1989 static void usbtest_disconnect (struct usb_interface *intf) 1992 1990 { 1993 1991 struct usbtest_dev *dev = usb_get_intfdata (intf); 1994 - 1995 - down (&dev->sem); 1996 1992 1997 1993 usb_set_intfdata (intf, NULL); 1998 1994 dev_dbg (&intf->dev, "disconnect\n");
+12 -10
drivers/usb/mon/mon_bin.c
··· 1026 1026 return mask; 1027 1027 } 1028 1028 1029 + #if 0 1030 + 1029 1031 /* 1030 1032 * open and close: just keep track of how many times the device is 1031 1033 * mapped, to use the proper memory allocation function. ··· 1047 1045 /* 1048 1046 * Map ring pages to user space. 1049 1047 */ 1050 - struct page *mon_bin_vma_nopage(struct vm_area_struct *vma, 1051 - unsigned long address, int *type) 1048 + static int mon_bin_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf) 1052 1049 { 1053 1050 struct mon_reader_bin *rp = vma->vm_private_data; 1054 1051 unsigned long offset, chunk_idx; 1055 1052 struct page *pageptr; 1056 1053 1057 - offset = (address - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT); 1054 + offset = vmf->pgoff << PAGE_SHIFT; 1058 1055 if (offset >= rp->b_size) 1059 - return NOPAGE_SIGBUS; 1056 + return VM_FAULT_SIGBUS; 1060 1057 chunk_idx = offset / CHUNK_SIZE; 1061 1058 pageptr = rp->b_vec[chunk_idx].pg; 1062 1059 get_page(pageptr); 1063 - if (type) 1064 - *type = VM_FAULT_MINOR; 1065 - return pageptr; 1060 + vmf->page = pageptr; 1061 + return 0; 1066 1062 } 1067 1063 1068 1064 struct vm_operations_struct mon_bin_vm_ops = { 1069 1065 .open = mon_bin_vma_open, 1070 1066 .close = mon_bin_vma_close, 1071 - .nopage = mon_bin_vma_nopage, 1067 + .fault = mon_bin_vma_fault, 1072 1068 }; 1073 1069 1074 1070 int mon_bin_mmap(struct file *filp, struct vm_area_struct *vma) 1075 1071 { 1076 - /* don't do anything here: "nopage" will set up page table entries */ 1072 + /* don't do anything here: "fault" will set up page table entries */ 1077 1073 vma->vm_ops = &mon_bin_vm_ops; 1078 1074 vma->vm_flags |= VM_RESERVED; 1079 1075 vma->vm_private_data = filp->private_data; ··· 1079 1079 return 0; 1080 1080 } 1081 1081 1082 - struct file_operations mon_fops_binary = { 1082 + #endif /* 0 */ 1083 + 1084 + static const struct file_operations mon_fops_binary = { 1083 1085 .owner = THIS_MODULE, 1084 1086 .open = mon_bin_open, 1085 1087 .llseek = no_llseek,
+25 -12
drivers/usb/serial/Kconfig
··· 2 2 # USB Serial device configuration 3 3 # 4 4 5 - menu "USB Serial Converter support" 6 - depends on USB!=n 7 - 8 - config USB_SERIAL 5 + menuconfig USB_SERIAL 9 6 tristate "USB Serial Converter support" 10 7 depends on USB 11 8 ---help--- ··· 16 19 17 20 To compile this driver as a module, choose M here: the 18 21 module will be called usbserial. 22 + 23 + if USB_SERIAL 19 24 20 25 config USB_SERIAL_CONSOLE 21 26 bool "USB Serial Console device support (EXPERIMENTAL)" ··· 41 42 port, /dev/ttyUSB0, as system console. 42 43 43 44 If unsure, say N. 45 + 46 + config USB_EZUSB 47 + bool "Functions for loading firmware on EZUSB chips" 48 + depends on USB_SERIAL 49 + help 50 + Say Y here if you need EZUSB device support. 44 51 45 52 config USB_SERIAL_GENERIC 46 53 bool "USB Generic Serial Driver" ··· 110 105 config USB_SERIAL_WHITEHEAT 111 106 tristate "USB ConnectTech WhiteHEAT Serial Driver" 112 107 depends on USB_SERIAL 108 + select USB_EZUSB 113 109 help 114 110 Say Y here if you want to use a ConnectTech WhiteHEAT 4 port 115 111 USB to serial converter device. ··· 288 282 To compile this driver as a module, choose M here: the 289 283 module will be called ipw. 290 284 285 + config USB_SERIAL_IUU 286 + tristate "USB Infinity USB Unlimited Phoenix Driver (Experimental)" 287 + depends on USB_SERIAL && EXPERIMENTAL 288 + help 289 + Say Y here if you want to use a IUU in phoenix mode and get 290 + an extra ttyUSBx device. More information available on 291 + http://eczema.ecze.com/iuu_phoenix.html 292 + 293 + To compile this driver as a module, choose M here: the 294 + module will be called iuu_phoenix.o 295 + 291 296 config USB_SERIAL_KEYSPAN_PDA 292 297 tristate "USB Keyspan PDA Single Port Serial Driver" 293 298 depends on USB_SERIAL 299 + select USB_EZUSB 294 300 help 295 301 Say Y here if you want to use a Keyspan PDA single port USB to 296 302 serial converter device. This driver makes use of firmware ··· 314 296 config USB_SERIAL_KEYSPAN 315 297 tristate "USB Keyspan USA-xxx Serial Driver" 316 298 depends on USB_SERIAL 299 + select USB_EZUSB 317 300 ---help--- 318 301 Say Y here if you want to use Keyspan USB to serial converter 319 302 devices. This driver makes use of Keyspan's official firmware ··· 557 538 config USB_SERIAL_XIRCOM 558 539 tristate "USB Xircom / Entregra Single Port Serial Driver" 559 540 depends on USB_SERIAL 541 + select USB_EZUSB 560 542 help 561 543 Say Y here if you want to use a Xircom or Entregra single port USB to 562 544 serial converter device. This driver makes use of firmware ··· 605 585 To compile this driver as a module, choose M here: the 606 586 module will be called usb-debug. 607 587 608 - config USB_EZUSB 609 - bool 610 - depends on USB_SERIAL_KEYSPAN_PDA || USB_SERIAL_XIRCOM || USB_SERIAL_KEYSPAN || USB_SERIAL_WHITEHEAT 611 - default y 612 - 613 - 614 - endmenu 615 - 588 + endif # USB_SERIAL
+1
drivers/usb/serial/Makefile
··· 30 30 obj-$(CONFIG_USB_SERIAL_HP4X) += hp4x.o 31 31 obj-$(CONFIG_USB_SERIAL_IPAQ) += ipaq.o 32 32 obj-$(CONFIG_USB_SERIAL_IPW) += ipw.o 33 + obj-$(CONFIG_USB_SERIAL_IUU) += iuu_phoenix.o 33 34 obj-$(CONFIG_USB_SERIAL_IR) += ir-usb.o 34 35 obj-$(CONFIG_USB_SERIAL_KEYSPAN) += keyspan.o 35 36 obj-$(CONFIG_USB_SERIAL_KEYSPAN_PDA) += keyspan_pda.o
+4 -1
drivers/usb/serial/airprime.c
··· 217 217 priv->rts_state = 0; 218 218 priv->dtr_state = 0; 219 219 220 - airprime_send_setup(port); 220 + mutex_lock(&port->serial->disc_mutex); 221 + if (!port->serial->disconnected) 222 + airprime_send_setup(port); 223 + mutex_lock(&port->serial->disc_mutex); 221 224 222 225 for (i = 0; i < NUM_READ_URBS; ++i) { 223 226 usb_kill_urb (priv->read_urbp[i]);
+3 -1
drivers/usb/serial/ark3116.c
··· 151 151 return 0; 152 152 153 153 cleanup: 154 - for (--i; i >= 0; --i) 154 + for (--i; i >= 0; --i) { 155 + kfree(usb_get_serial_port_data(serial->port[i])); 155 156 usb_set_serial_port_data(serial->port[i], NULL); 157 + } 156 158 return -ENOMEM; 157 159 } 158 160
+15 -20
drivers/usb/serial/belkin_sa.c
··· 350 350 unsigned long control_state; 351 351 int bad_flow_control; 352 352 speed_t baud; 353 + struct ktermios *termios = port->tty->termios; 353 354 354 - if ((!port->tty) || (!port->tty->termios)) { 355 - dbg ("%s - no tty or termios structure", __FUNCTION__); 356 - return; 357 - } 355 + iflag = termios->c_iflag; 356 + cflag = termios->c_cflag; 358 357 359 - iflag = port->tty->termios->c_iflag; 360 - cflag = port->tty->termios->c_cflag; 358 + termios->c_cflag &= ~CMSPAR; 361 359 362 360 /* get a local copy of the current port settings */ 363 361 spin_lock_irqsave(&priv->lock, flags); ··· 367 369 old_cflag = old_termios->c_cflag; 368 370 369 371 /* Set the baud rate */ 370 - if( (cflag&CBAUD) != (old_cflag&CBAUD) ) { 372 + if ((cflag & CBAUD) != (old_cflag & CBAUD)) { 371 373 /* reassert DTR and (maybe) RTS on transition from B0 */ 372 374 if( (old_cflag&CBAUD) == B0 ) { 373 375 control_state |= (TIOCM_DTR|TIOCM_RTS); 374 376 if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 1) < 0) 375 377 err("Set DTR error"); 376 378 /* don't set RTS if using hardware flow control */ 377 - if (!(old_cflag&CRTSCTS) ) 379 + if (!(old_cflag & CRTSCTS)) 378 380 if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 1) < 0) 379 381 err("Set RTS error"); 380 382 } 381 383 } 382 384 383 385 baud = tty_get_baud_rate(port->tty); 384 - if (baud == 0) { 385 - dbg("%s - tty_get_baud_rate says 0 baud", __FUNCTION__); 386 - return; 387 - } 388 - urb_value = BELKIN_SA_BAUD(baud); 389 - /* Clip to maximum speed */ 390 - if (urb_value == 0) 391 - urb_value = 1; 392 - /* Turn it back into a resulting real baud rate */ 393 - baud = BELKIN_SA_BAUD(urb_value); 394 - /* FIXME: Once the tty updates are done then push this back to the tty */ 386 + if (baud) { 387 + urb_value = BELKIN_SA_BAUD(baud); 388 + /* Clip to maximum speed */ 389 + if (urb_value == 0) 390 + urb_value = 1; 391 + /* Turn it back into a resulting real baud rate */ 392 + baud = BELKIN_SA_BAUD(urb_value); 395 393 396 - if ((cflag & CBAUD) != B0 ) { 394 + /* Report the actual baud rate back to the caller */ 395 + tty_encode_baud_rate(port->tty, baud, baud); 397 396 if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0) 398 397 err("Set baudrate error"); 399 398 } else {
+54 -36
drivers/usb/serial/console.c
··· 64 64 struct usb_serial *serial; 65 65 struct usb_serial_port *port; 66 66 int retval = 0; 67 - struct tty_struct *tty; 68 - struct ktermios *termios; 67 + struct tty_struct *tty = NULL; 68 + struct ktermios *termios = NULL, dummy; 69 69 70 70 dbg ("%s", __FUNCTION__); 71 71 ··· 133 133 } 134 134 co->cflag = cflag; 135 135 136 - /* grab the first serial port that happens to be connected */ 137 - serial = usb_serial_get_by_index(0); 136 + /* 137 + * no need to check the index here: if the index is wrong, console 138 + * code won't call us 139 + */ 140 + serial = usb_serial_get_by_index(co->index); 138 141 if (serial == NULL) { 139 142 /* no device is connected yet, sorry :( */ 140 - err ("No USB device connected to ttyUSB0"); 143 + err ("No USB device connected to ttyUSB%i", co->index); 141 144 return -ENODEV; 142 145 } 143 146 ··· 151 148 152 149 ++port->open_count; 153 150 if (port->open_count == 1) { 151 + if (serial->type->set_termios) { 152 + /* 153 + * allocate a fake tty so the driver can initialize 154 + * the termios structure, then later call set_termios to 155 + * configure according to command line arguments 156 + */ 157 + tty = kzalloc(sizeof(*tty), GFP_KERNEL); 158 + if (!tty) { 159 + retval = -ENOMEM; 160 + err("no more memory"); 161 + goto reset_open_count; 162 + } 163 + termios = kzalloc(sizeof(*termios), GFP_KERNEL); 164 + if (!termios) { 165 + retval = -ENOMEM; 166 + err("no more memory"); 167 + goto free_tty; 168 + } 169 + memset(&dummy, 0, sizeof(struct ktermios)); 170 + tty->termios = termios; 171 + port->tty = tty; 172 + } 173 + 154 174 /* only call the device specific open if this 155 175 * is the first time the port is opened */ 156 176 if (serial->type->open) 157 177 retval = serial->type->open(port, NULL); 158 178 else 159 179 retval = usb_serial_generic_open(port, NULL); 160 - if (retval) 161 - port->open_count = 0; 162 - } 163 180 164 - if (retval) { 165 - err ("could not open USB console port"); 166 - return retval; 167 - } 168 - 169 - if (serial->type->set_termios) { 170 - struct ktermios dummy; 171 - /* build up a fake tty structure so that the open call has something 172 - * to look at to get the cflag value */ 173 - tty = kzalloc(sizeof(*tty), GFP_KERNEL); 174 - if (!tty) { 175 - err ("no more memory"); 176 - return -ENOMEM; 181 + if (retval) { 182 + err("could not open USB console port"); 183 + goto free_termios; 177 184 } 178 - termios = kzalloc(sizeof(*termios), GFP_KERNEL); 179 - if (!termios) { 180 - err ("no more memory"); 181 - kfree (tty); 182 - return -ENOMEM; 183 - } 184 - memset(&dummy, 0, sizeof(struct ktermios)); 185 - termios->c_cflag = cflag; 186 - tty->termios = termios; 187 - port->tty = tty; 188 185 189 - /* set up the initial termios settings */ 190 - serial->type->set_termios(port, &dummy); 191 - port->tty = NULL; 192 - kfree (termios); 193 - kfree (tty); 186 + if (serial->type->set_termios) { 187 + termios->c_cflag = cflag; 188 + serial->type->set_termios(port, &dummy); 189 + 190 + port->tty = NULL; 191 + kfree(termios); 192 + kfree(tty); 193 + } 194 194 } 195 195 196 + port->console = 1; 197 + retval = 0; 198 + 199 + out: 196 200 return retval; 201 + free_termios: 202 + kfree(termios); 203 + port->tty = NULL; 204 + free_tty: 205 + kfree(tty); 206 + reset_open_count: 207 + port->open_count = 0; 208 + goto out; 197 209 } 198 210 199 211 static void usb_console_write(struct console *co, const char *buf, unsigned count)
+10 -1
drivers/usb/serial/cp2101.c
··· 59 59 { USB_DEVICE(0x10A6, 0xAA26) }, /* Knock-off DCU-11 cable */ 60 60 { USB_DEVICE(0x10AB, 0x10C5) }, /* Siemens MC60 Cable */ 61 61 { USB_DEVICE(0x10B5, 0xAC70) }, /* Nokia CA-42 USB */ 62 + { USB_DEVICE(0x10C4, 0x800A) }, /* SPORTident BSM7-D-USB main station */ 62 63 { USB_DEVICE(0x10C4, 0x803B) }, /* Pololu USB-serial converter */ 63 64 { USB_DEVICE(0x10C4, 0x8053) }, /* Enfora EDG1228 */ 64 65 { USB_DEVICE(0x10C4, 0x8066) }, /* Argussoft In-System Programmer */ ··· 77 76 { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */ 78 77 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ 79 78 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */ 79 + { USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */ 80 + { USB_DEVICE(0x10C4, 0xF002) }, /* Elan Digital Systems USBwave12 */ 81 + { USB_DEVICE(0x10C4, 0xF003) }, /* Elan Digital Systems USBpulse100 */ 82 + { USB_DEVICE(0x10C4, 0xF004) }, /* Elan Digital Systems USBcount50 */ 80 83 { USB_DEVICE(0x10C5, 0xEA61) }, /* Silicon Labs MobiData GPRS USB Modem */ 81 84 { USB_DEVICE(0x13AD, 0x9999) }, /* Baltech card reader */ 85 + { USB_DEVICE(0x166A, 0x0303) }, /* Clipsal 5500PCU C-Bus USB interface */ 82 86 { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */ 83 87 { } /* Terminating Entry */ 84 88 }; ··· 348 342 usb_kill_urb(port->write_urb); 349 343 usb_kill_urb(port->read_urb); 350 344 351 - cp2101_set_config_single(port, CP2101_UART, UART_DISABLE); 345 + mutex_lock(&port->serial->disc_mutex); 346 + if (!port->serial->disconnected) 347 + cp2101_set_config_single(port, CP2101_UART, UART_DISABLE); 348 + mutex_unlock(&port->serial->disc_mutex); 352 349 } 353 350 354 351 /*
-1
drivers/usb/serial/cyberjack.c
··· 319 319 /* React only to interrupts signaling a bulk_in transfer */ 320 320 if( (urb->actual_length==4) && (data[0]==0x01) ) { 321 321 short old_rdtodo; 322 - int result; 323 322 324 323 /* This is a announcement of coming bulk_ins. */ 325 324 unsigned short size = ((unsigned short)data[3]<<8)+data[2]+3;
+16 -9
drivers/usb/serial/cypress_m8.c
··· 682 682 { 683 683 struct cypress_private *priv = usb_get_serial_port_data(port); 684 684 unsigned int c_cflag; 685 - unsigned long flags; 686 685 int bps; 687 686 long timeout; 688 687 wait_queue_t wait; ··· 689 690 dbg("%s - port %d", __FUNCTION__, port->number); 690 691 691 692 /* wait for data to drain from buffer */ 692 - spin_lock_irqsave(&priv->lock, flags); 693 + spin_lock_irq(&priv->lock); 693 694 timeout = CYPRESS_CLOSING_WAIT; 694 695 init_waitqueue_entry(&wait, current); 695 696 add_wait_queue(&port->tty->write_wait, &wait); ··· 697 698 set_current_state(TASK_INTERRUPTIBLE); 698 699 if (cypress_buf_data_avail(priv->buf) == 0 699 700 || timeout == 0 || signal_pending(current) 700 - || !usb_get_intfdata(port->serial->interface)) 701 + /* without mutex, allowed due to harmless failure mode */ 702 + || port->serial->disconnected) 701 703 break; 702 - spin_unlock_irqrestore(&priv->lock, flags); 704 + spin_unlock_irq(&priv->lock); 703 705 timeout = schedule_timeout(timeout); 704 - spin_lock_irqsave(&priv->lock, flags); 706 + spin_lock_irq(&priv->lock); 705 707 } 706 708 set_current_state(TASK_RUNNING); 707 709 remove_wait_queue(&port->tty->write_wait, &wait); 708 710 /* clear out any remaining data in the buffer */ 709 711 cypress_buf_clear(priv->buf); 710 - spin_unlock_irqrestore(&priv->lock, flags); 711 - 712 + spin_unlock_irq(&priv->lock); 713 + 714 + /* writing is potentially harmful, lock must be taken */ 715 + mutex_lock(&port->serial->disc_mutex); 716 + if (port->serial->disconnected) { 717 + mutex_unlock(&port->serial->disc_mutex); 718 + return; 719 + } 712 720 /* wait for characters to drain from device */ 713 721 bps = tty_get_baud_rate(port->tty); 714 722 if (bps > 1200) ··· 733 727 if (c_cflag & HUPCL) { 734 728 /* drop dtr and rts */ 735 729 priv = usb_get_serial_port_data(port); 736 - spin_lock_irqsave(&priv->lock, flags); 730 + spin_lock_irq(&priv->lock); 737 731 priv->line_control = 0; 738 732 priv->cmd_ctrl = 1; 739 - spin_unlock_irqrestore(&priv->lock, flags); 733 + spin_unlock_irq(&priv->lock); 740 734 cypress_write(port, NULL, 0); 741 735 } 742 736 } ··· 744 738 if (stats) 745 739 dev_info (&port->dev, "Statistics: %d Bytes In | %d Bytes Out | %d Commands Issued\n", 746 740 priv->bytes_in, priv->bytes_out, priv->cmd_count); 741 + mutex_unlock(&port->serial->disc_mutex); 747 742 } /* cypress_close */ 748 743 749 744
+7 -6
drivers/usb/serial/digi_acceleport.c
··· 1405 1405 unsigned char buf[32]; 1406 1406 struct tty_struct *tty = port->tty; 1407 1407 struct digi_port *priv = usb_get_serial_port_data(port); 1408 - unsigned long flags = 0; 1409 1408 1410 1409 dbg("digi_close: TOP: port=%d, open_count=%d", 1411 1410 priv->dp_port_num, port->open_count); 1412 1411 1412 + mutex_lock(&port->serial->disc_mutex); 1413 1413 /* if disconnected, just clear flags */ 1414 - if (!usb_get_intfdata(port->serial->interface)) 1414 + if (port->serial->disconnected) 1415 1415 goto exit; 1416 1416 1417 1417 /* do cleanup only after final close on this port */ 1418 - spin_lock_irqsave(&priv->dp_port_lock, flags); 1418 + spin_lock_irq(&priv->dp_port_lock); 1419 1419 priv->dp_in_close = 1; 1420 - spin_unlock_irqrestore(&priv->dp_port_lock, flags); 1420 + spin_unlock_irq(&priv->dp_port_lock); 1421 1421 1422 1422 /* tell line discipline to process only XON/XOFF */ 1423 1423 tty->closing = 1; ··· 1482 1482 } 1483 1483 tty->closing = 0; 1484 1484 exit: 1485 - spin_lock_irqsave(&priv->dp_port_lock, flags); 1485 + spin_lock_irq(&priv->dp_port_lock); 1486 1486 priv->dp_write_urb_in_use = 0; 1487 1487 priv->dp_in_close = 0; 1488 1488 wake_up_interruptible(&priv->dp_close_wait); 1489 - spin_unlock_irqrestore(&priv->dp_port_lock, flags); 1489 + spin_unlock_irq(&priv->dp_port_lock); 1490 + mutex_unlock(&port->serial->disc_mutex); 1490 1491 dbg("digi_close: done"); 1491 1492 } 1492 1493
+2 -2
drivers/usb/serial/ezusb.c
··· 53 53 } 54 54 55 55 56 - EXPORT_SYMBOL(ezusb_writememory); 57 - EXPORT_SYMBOL(ezusb_set_reset); 56 + EXPORT_SYMBOL_GPL(ezusb_writememory); 57 + EXPORT_SYMBOL_GPL(ezusb_set_reset); 58 58
+41 -252
drivers/usb/serial/ftdi_sio.c
··· 17 17 * See http://ftdi-usb-sio.sourceforge.net for upto date testing info 18 18 * and extra documentation 19 19 * 20 - * (21/Jul/2004) Ian Abbott 21 - * Incorporated Steven Turner's code to add support for the FT2232C chip. 22 - * The prelimilary port to the 2.6 kernel was by Rus V. Brushkoff. I have 23 - * fixed a couple of things. 24 - * 25 - * (27/May/2004) Ian Abbott 26 - * Improved throttling code, mostly stolen from the WhiteHEAT driver. 27 - * 28 - * (26/Mar/2004) Jan Capek 29 - * Added PID's for ICD-U20/ICD-U40 - incircuit PIC debuggers from CCS Inc. 30 - * 31 - * (09/Feb/2004) Ian Abbott 32 - * Changed full name of USB-UIRT device to avoid "/" character. 33 - * Added FTDI's alternate PID (0x6006) for FT232/245 devices. 34 - * Added PID for "ELV USB Module UO100" from Stefan Frings. 35 - * 36 - * (21/Oct/2003) Ian Abbott 37 - * Renamed some VID/PID macros for Matrix Orbital and Perle Systems 38 - * devices. Removed Matrix Orbital and Perle Systems devices from the 39 - * 8U232AM device table, but left them in the FT232BM table, as they are 40 - * known to use only FT232BM. 41 - * 42 - * (17/Oct/2003) Scott Allen 43 - * Added vid/pid for Perle Systems UltraPort USB serial converters 44 - * 45 - * (21/Sep/2003) Ian Abbott 46 - * Added VID/PID for Omnidirectional Control Technology US101 USB to 47 - * RS-232 adapter (also rebadged as Dick Smith Electronics XH6381). 48 - * VID/PID supplied by Donald Gordon. 49 - * 50 - * (19/Aug/2003) Ian Abbott 51 - * Freed urb's transfer buffer in write bulk callback. 52 - * Omitted some paranoid checks in write bulk callback that don't matter. 53 - * Scheduled work in write bulk callback regardless of port's open count. 54 - * 55 - * (05/Aug/2003) Ian Abbott 56 - * Added VID/PID for ID TECH IDT1221U USB to RS-232 adapter. 57 - * VID/PID provided by Steve Briggs. 58 - * 59 - * (23/Jul/2003) Ian Abbott 60 - * Added PIDs for CrystalFontz 547, 633, 631, 635, 640 and 640 from 61 - * Wayne Wylupski. 62 - * 63 - * (10/Jul/2003) David Glance 64 - * Added PID for DSS-20 SyncStation cradle for Sony-Ericsson P800. 65 - * 66 - * (27/Jun/2003) Ian Abbott 67 - * Reworked the urb handling logic. We have no more pool, but dynamically 68 - * allocate the urb and the transfer buffer on the fly. In testing this 69 - * does not incure any measurable overhead. This also relies on the fact 70 - * that we have proper reference counting logic for urbs. I nicked this 71 - * from Greg KH's Visor driver. 72 - * 73 - * (23/Jun/2003) Ian Abbott 74 - * Reduced flip buffer pushes and corrected a data length test in 75 - * ftdi_read_bulk_callback. 76 - * Defererence pointers after any paranoid checks, not before. 77 - * 78 - * (21/Jun/2003) Erik Nygren 79 - * Added support for Home Electronics Tira-1 IR transceiver using FT232BM chip. 80 - * See <http://www.home-electro.com/tira1.htm>. Only operates properly 81 - * at 100000 and RTS-CTS, so set custom divisor mode on startup. 82 - * Also force the Tira-1 and USB-UIRT to only use their custom baud rates. 83 - * 84 - * (18/Jun/2003) Ian Abbott 85 - * Added Device ID of the USB relais from Rudolf Gugler (backported from 86 - * Philipp Gühring's patch for 2.5.x kernel). 87 - * Moved read transfer buffer reallocation into startup function. 88 - * Free existing write urb and transfer buffer in startup function. 89 - * Only use urbs in write urb pool that were successfully allocated. 90 - * Moved some constant macros out of functions. 91 - * Minor whitespace and comment changes. 92 - * 93 - * (12/Jun/2003) David Norwood 94 - * Added support for USB-UIRT IR transceiver using 8U232AM chip. 95 - * See <http://home.earthlink.net/~jrhees/USBUIRT/index.htm>. Only 96 - * operates properly at 312500, so set custom divisor mode on startup. 97 - * 98 - * (12/Jun/2003) Ian Abbott 99 - * Added Sealevel SeaLINK+ 210x, 220x, 240x, 280x vid/pids from Tuan Hoang 100 - * - I've eliminated some that don't seem to exist! 101 - * Added Home Electronics Tira-1 IR transceiver pid from Chris Horn 102 - * Some whitespace/coding-style cleanups 103 - * 104 - * (11/Jun/2003) Ian Abbott 105 - * Fixed unsafe spinlock usage in ftdi_write 106 - * 107 - * (24/Feb/2003) Richard Shooter 108 - * Increase read buffer size to improve read speeds at higher baud rates 109 - * (specifically tested with up to 1Mb/sec at 1.5M baud) 110 - * 111 - * (23/Feb/2003) John Wilkins 112 - * Added Xon/xoff flow control (activating support in the ftdi device) 113 - * Added vid/pid for Videonetworks/Homechoice (UK ISP) 114 - * 115 - * (23/Feb/2003) Bill Ryder 116 - * Added matrix orb device vid/pids from Wayne Wylupski 117 - * 118 - * (19/Feb/2003) Ian Abbott 119 - * For TIOCSSERIAL, set alt_speed to 0 when ASYNC_SPD_MASK value has 120 - * changed to something other than ASYNC_SPD_HI, ASYNC_SPD_VHI, 121 - * ASYNC_SPD_SHI or ASYNC_SPD_WARP. Also, unless ASYNC_SPD_CUST is in 122 - * force, don't bother changing baud rate when custom_divisor has changed. 123 - * 124 - * (18/Feb/2003) Ian Abbott 125 - * Fixed TIOCMGET handling to include state of DTR and RTS, the state 126 - * of which are now saved by set_dtr() and set_rts(). 127 - * Fixed improper storage class for buf in set_dtr() and set_rts(). 128 - * Added FT232BM chip type and support for its extra baud rates (compared 129 - * to FT8U232AM). 130 - * Took account of special case divisor values for highest baud rates of 131 - * FT8U232AM and FT232BM. 132 - * For TIOCSSERIAL, forced alt_speed to 0 when ASYNC_SPD_CUST kludge used, 133 - * as previous alt_speed setting is now stale. 134 - * Moved startup code common between the startup routines for the 135 - * different chip types into a common subroutine. 136 - * 137 - * (17/Feb/2003) Bill Ryder 138 - * Added write urb buffer pool on a per device basis 139 - * Added more checking for open file on callbacks (fixed OOPS) 140 - * Added CrystalFontz 632 and 634 PIDs 141 - * (thanx to CrystalFontz for the sample devices - they flushed out 142 - * some driver bugs) 143 - * Minor debugging message changes 144 - * Added throttle, unthrottle and chars_in_buffer functions 145 - * Fixed FTDI_SIO (the original device) bug 146 - * Fixed some shutdown handling 147 - * 148 - * 149 - * 150 - * 151 - * (07/Jun/2002) Kuba Ober 152 - * Changed FTDI_SIO_BASE_BAUD_TO_DIVISOR macro into ftdi_baud_to_divisor 153 - * function. It was getting too complex. 154 - * Fix the divisor calculation logic which was setting divisor of 0.125 155 - * instead of 0.5 for fractional parts of divisor equal to 5/8, 6/8, 7/8. 156 - * Also make it bump up the divisor to next integer in case of 7/8 - it's 157 - * a better approximation. 158 - * 159 - * (25/Jul/2002) Bill Ryder inserted Dmitri's TIOCMIWAIT patch 160 - * Not tested by me but it doesn't break anything I use. 161 - * 162 - * (04/Jan/2002) Kuba Ober 163 - * Implemented 38400 baudrate kludge, where it can be substituted with other 164 - * values. That's the only way to set custom baudrates. 165 - * Implemented TIOCSSERIAL, TIOCGSERIAL ioctl's so that setserial is happy. 166 - * FIXME: both baudrate things should eventually go to usbserial.c as other 167 - * devices may need that functionality too. Actually, it can probably be 168 - * merged in serial.c somehow - too many drivers repeat this code over 169 - * and over. 170 - * Fixed baudrate forgetfulness - open() used to reset baudrate to 9600 every time. 171 - * Divisors for baudrates are calculated by a macro. 172 - * Small code cleanups. Ugly whitespace changes for Plato's sake only ;-]. 173 - * 174 - * (04/Nov/2001) Bill Ryder 175 - * Fixed bug in read_bulk_callback where incorrect urb buffer was used. 176 - * Cleaned up write offset calculation 177 - * Added write_room since default values can be incorrect for sio 178 - * Changed write_bulk_callback to use same queue_task as other drivers 179 - * (the previous version caused panics) 180 - * Removed port iteration code since the device only has one I/O port and it 181 - * was wrong anyway. 182 - * 183 - * (31/May/2001) gkh 184 - * Switched from using spinlock to a semaphore, which fixes lots of problems. 185 - * 186 - * (23/May/2001) Bill Ryder 187 - * Added runtime debug patch (thanx Tyson D Sawyer). 188 - * Cleaned up comments for 8U232 189 - * Added parity, framing and overrun error handling 190 - * Added receive break handling. 191 - * 192 - * (04/08/2001) gb 193 - * Identify version on module load. 194 - * 195 - * (18/March/2001) Bill Ryder 196 - * (Not released) 197 - * Added send break handling. (requires kernel patch too) 198 - * Fixed 8U232AM hardware RTS/CTS etc status reporting. 199 - * Added flipbuf fix copied from generic device 200 - * 201 - * (12/3/2000) Bill Ryder 202 - * Added support for 8U232AM device. 203 - * Moved PID and VIDs into header file only. 204 - * Turned on low-latency for the tty (device will do high baudrates) 205 - * Added shutdown routine to close files when device removed. 206 - * More debug and error message cleanups. 207 - * 208 - * (11/13/2000) Bill Ryder 209 - * Added spinlock protected open code and close code. 210 - * Multiple opens work (sort of - see webpage mentioned above). 211 - * Cleaned up comments. Removed multiple PID/VID definitions. 212 - * Factorised cts/dtr code 213 - * Made use of __FUNCTION__ in dbg's 214 - * 215 - * (11/01/2000) Adam J. Richter 216 - * usb_device_id table support 217 - * 218 - * (10/05/2000) gkh 219 - * Fixed bug with urb->dev not being set properly, now that the usb 220 - * core needs it. 221 - * 222 - * (09/11/2000) gkh 223 - * Removed DEBUG #ifdefs with call to usb_serial_debug_data 224 - * 225 - * (07/19/2000) gkh 226 - * Added module_init and module_exit functions to handle the fact that this 227 - * driver is a loadable module now. 228 - * 229 - * (04/04/2000) Bill Ryder 230 - * Fixed bugs in TCGET/TCSET ioctls (by removing them - they are 231 - * handled elsewhere in the tty io driver chain). 232 - * 233 - * (03/30/2000) Bill Ryder 234 - * Implemented lots of ioctls 235 - * Fixed a race condition in write 236 - * Changed some dbg's to errs 237 - * 238 - * (03/26/2000) gkh 239 - * Split driver up into device specific pieces. 20 + * Change entries from 2004 and earlier can be found in versions of this 21 + * file in kernel versions prior to the 2.6.24 release. 240 22 * 241 23 */ 242 24 ··· 91 309 void (*port_probe)(struct ftdi_private *); /* Special settings for probed ports. */ 92 310 }; 93 311 94 - static int ftdi_olimex_probe (struct usb_serial *serial); 312 + static int ftdi_jtag_probe (struct usb_serial *serial); 95 313 static void ftdi_USB_UIRT_setup (struct ftdi_private *priv); 96 314 static void ftdi_HE_TIRA1_setup (struct ftdi_private *priv); 97 315 98 - static struct ftdi_sio_quirk ftdi_olimex_quirk = { 99 - .probe = ftdi_olimex_probe, 316 + static struct ftdi_sio_quirk ftdi_jtag_quirk = { 317 + .probe = ftdi_jtag_probe, 100 318 }; 101 319 102 320 static struct ftdi_sio_quirk ftdi_USB_UIRT_quirk = { ··· 253 471 { USB_DEVICE(FTDI_VID, FTDI_IBS_PEDO_PID) }, 254 472 { USB_DEVICE(FTDI_VID, FTDI_IBS_PROD_PID) }, 255 473 /* 256 - * These will probably use user-space drivers. Uncomment them if 257 - * you need them or use the user-specified vendor/product module 258 - * parameters (see ftdi_sio.h for the numbers). Make a fuss if 259 - * you think the driver should recognize any of them by default. 474 + * Due to many user requests for multiple ELV devices we enable 475 + * them by default. 260 476 */ 261 - /* { USB_DEVICE(FTDI_VID, FTDI_ELV_CLI7000_PID) }, */ 262 - /* { USB_DEVICE(FTDI_VID, FTDI_ELV_PPS7330_PID) }, */ 263 - /* { USB_DEVICE(FTDI_VID, FTDI_ELV_TFM100_PID) }, */ 264 - /* { USB_DEVICE(FTDI_VID, FTDI_ELV_UDF77_PID) }, */ 265 - /* { USB_DEVICE(FTDI_VID, FTDI_ELV_UIO88_PID) }, */ 266 - /* { USB_DEVICE(FTDI_VID, FTDI_ELV_UAD8_PID) }, */ 267 - /* { USB_DEVICE(FTDI_VID, FTDI_ELV_UDA7_PID) }, */ 268 - /* { USB_DEVICE(FTDI_VID, FTDI_ELV_USI2_PID) }, */ 269 - /* { USB_DEVICE(FTDI_VID, FTDI_ELV_T1100_PID) }, */ 270 - /* { USB_DEVICE(FTDI_VID, FTDI_ELV_PCD200_PID) }, */ 271 - /* { USB_DEVICE(FTDI_VID, FTDI_ELV_ULA200_PID) }, */ 272 - /* { USB_DEVICE(FTDI_VID, FTDI_ELV_CSI8_PID) }, */ 273 - /* { USB_DEVICE(FTDI_VID, FTDI_ELV_EM1000DL_PID) }, */ 274 - /* { USB_DEVICE(FTDI_VID, FTDI_ELV_PCK100_PID) }, */ 275 - /* { USB_DEVICE(FTDI_VID, FTDI_ELV_RFP500_PID) }, */ 276 - /* { USB_DEVICE(FTDI_VID, FTDI_ELV_FS20SIG_PID) }, */ 277 - /* { USB_DEVICE(FTDI_VID, FTDI_ELV_WS300PC_PID) }, */ 278 - /* { USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1300PC_PID) }, */ 279 - /* { USB_DEVICE(FTDI_VID, FTDI_ELV_WS500_PID) }, */ 477 + { USB_DEVICE(FTDI_VID, FTDI_ELV_CLI7000_PID) }, 478 + { USB_DEVICE(FTDI_VID, FTDI_ELV_PPS7330_PID) }, 479 + { USB_DEVICE(FTDI_VID, FTDI_ELV_TFM100_PID) }, 480 + { USB_DEVICE(FTDI_VID, FTDI_ELV_UDF77_PID) }, 481 + { USB_DEVICE(FTDI_VID, FTDI_ELV_UIO88_PID) }, 482 + { USB_DEVICE(FTDI_VID, FTDI_ELV_UAD8_PID) }, 483 + { USB_DEVICE(FTDI_VID, FTDI_ELV_UDA7_PID) }, 484 + { USB_DEVICE(FTDI_VID, FTDI_ELV_USI2_PID) }, 485 + { USB_DEVICE(FTDI_VID, FTDI_ELV_T1100_PID) }, 486 + { USB_DEVICE(FTDI_VID, FTDI_ELV_PCD200_PID) }, 487 + { USB_DEVICE(FTDI_VID, FTDI_ELV_ULA200_PID) }, 488 + { USB_DEVICE(FTDI_VID, FTDI_ELV_CSI8_PID) }, 489 + { USB_DEVICE(FTDI_VID, FTDI_ELV_EM1000DL_PID) }, 490 + { USB_DEVICE(FTDI_VID, FTDI_ELV_PCK100_PID) }, 491 + { USB_DEVICE(FTDI_VID, FTDI_ELV_RFP500_PID) }, 492 + { USB_DEVICE(FTDI_VID, FTDI_ELV_FS20SIG_PID) }, 493 + { USB_DEVICE(FTDI_VID, FTDI_ELV_WS300PC_PID) }, 494 + { USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1300PC_PID) }, 495 + { USB_DEVICE(FTDI_VID, FTDI_ELV_WS500_PID) }, 280 496 { USB_DEVICE(FTDI_VID, LINX_SDMUSBQSS_PID) }, 281 497 { USB_DEVICE(FTDI_VID, LINX_MASTERDEVEL2_PID) }, 282 498 { USB_DEVICE(FTDI_VID, LINX_FUTURE_0_PID) }, ··· 325 545 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16C_PID) }, 326 546 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16HR_PID) }, 327 547 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16HRC_PID) }, 548 + { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16IC_PID) }, 328 549 { USB_DEVICE(KOBIL_VID, KOBIL_CONV_B1_PID) }, 329 550 { USB_DEVICE(KOBIL_VID, KOBIL_CONV_KAAN_PID) }, 330 551 { USB_DEVICE(POSIFLEX_VID, POSIFLEX_PP7000_PID) }, ··· 350 569 { USB_DEVICE(TELLDUS_VID, TELLDUS_TELLSTICK_PID) }, 351 570 { USB_DEVICE(FTDI_VID, FTDI_MAXSTREAM_PID) }, 352 571 { USB_DEVICE(TML_VID, TML_USB_SERIAL_PID) }, 572 + { USB_DEVICE(FTDI_VID, FTDI_ELSTER_UNICOM_PID) }, 353 573 { USB_DEVICE(OLIMEX_VID, OLIMEX_ARM_USB_OCD_PID), 354 - .driver_info = (kernel_ulong_t)&ftdi_olimex_quirk }, 574 + .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 575 + { USB_DEVICE(FIC_VID, FIC_NEO1973_DEBUG_PID), 576 + .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 577 + { USB_DEVICE(FTDI_VID, FTDI_OOCDLINK_PID), 578 + .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 355 579 { }, /* Optional parameter entry */ 356 580 { } /* Terminating entry */ 357 581 }; ··· 1069 1283 } /* ftdi_HE_TIRA1_setup */ 1070 1284 1071 1285 /* 1072 - * First port on Olimex arm-usb-ocd is reserved for JTAG interface 1073 - * and can be accessed from userspace using openocd. 1286 + * First port on JTAG adaptors such as Olimex arm-usb-ocd or the FIC/OpenMoko 1287 + * Neo1973 Debug Board is reserved for JTAG interface and can be accessed from 1288 + * userspace using openocd. 1074 1289 */ 1075 - static int ftdi_olimex_probe(struct usb_serial *serial) 1290 + static int ftdi_jtag_probe(struct usb_serial *serial) 1076 1291 { 1077 1292 struct usb_device *udev = serial->dev; 1078 1293 struct usb_interface *interface = serial->interface; ··· 1081 1294 dbg("%s",__FUNCTION__); 1082 1295 1083 1296 if (interface == udev->actconfig->interface[0]) { 1084 - info("Ignoring reserved serial port on Olimex arm-usb-ocd\n"); 1297 + info("Ignoring serial port reserved for JTAG"); 1085 1298 return -ENODEV; 1086 1299 } 1087 1300 ··· 1198 1411 1199 1412 dbg("%s", __FUNCTION__); 1200 1413 1201 - if (c_cflag & HUPCL){ 1414 + mutex_lock(&port->serial->disc_mutex); 1415 + if (c_cflag & HUPCL && !port->serial->disconnected){ 1202 1416 /* Disable flow control */ 1203 1417 if (usb_control_msg(port->serial->dev, 1204 1418 usb_sndctrlpipe(port->serial->dev, 0), ··· 1213 1425 /* drop RTS and DTR */ 1214 1426 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); 1215 1427 } /* Note change no line if hupcl is off */ 1428 + mutex_unlock(&port->serial->disc_mutex); 1216 1429 1217 1430 /* cancel any scheduled reading */ 1218 1431 cancel_delayed_work(&priv->rx_work);
+15
drivers/usb/serial/ftdi_sio.h
··· 98 98 #define FTDI_MTXORB_5_PID 0xFA05 /* Matrix Orbital Product Id */ 99 99 #define FTDI_MTXORB_6_PID 0xFA06 /* Matrix Orbital Product Id */ 100 100 101 + /* OOCDlink by Joern Kaipf <joernk@web.de> 102 + * (http://www.joernonline.de/dw/doku.php?id=start&idx=projects:oocdlink) */ 103 + #define FTDI_OOCDLINK_PID 0xbaf8 /* Amontec JTAGkey */ 104 + 101 105 /* Interbiometrics USB I/O Board */ 102 106 /* Developed for Interbiometrics by Rudolf Gugler */ 103 107 #define INTERBIOMETRICS_VID 0x1209 ··· 249 245 #define FTDI_ELV_WS300PC_PID 0xE0F6 /* PC-Wetterstation (WS 300 PC) */ 250 246 #define FTDI_ELV_FHZ1300PC_PID 0xE0E8 /* FHZ 1300 PC */ 251 247 #define FTDI_ELV_WS500_PID 0xE0E9 /* PC-Wetterstation (WS 500) */ 248 + #define FTDI_ELV_EM1010PC_PID 0xE0EF /* Engery monitor EM 1010 PC */ 252 249 253 250 /* 254 251 * Definitions for ID TECH (www.idt-net.com) devices ··· 283 278 #define FTDI_ATIK_ATK16C_PID 0xDF32 /* ATIK ATK-16C Colour Camera */ 284 279 #define FTDI_ATIK_ATK16HR_PID 0xDF31 /* ATIK ATK-16HR Grayscale Camera */ 285 280 #define FTDI_ATIK_ATK16HRC_PID 0xDF33 /* ATIK ATK-16HRC Colour Camera */ 281 + #define FTDI_ATIK_ATK16IC_PID 0xDF35 /* ATIK ATK-16IC Grayscale Camera */ 286 282 287 283 /* 288 284 * Protego product ids ··· 540 534 #define OLIMEX_VID 0x15BA 541 535 #define OLIMEX_ARM_USB_OCD_PID 0x0003 542 536 537 + /* www.elsterelectricity.com Elster Unicom III Optical Probe */ 538 + #define FTDI_ELSTER_UNICOM_PID 0xE700 /* Product Id */ 543 539 544 540 /* 545 541 * The Mobility Lab (TML) ··· 562 554 #define FTDI_SIO_SET_LATENCY_TIMER 9 /* Set the latency timer */ 563 555 #define FTDI_SIO_GET_LATENCY_TIMER 10 /* Get the latency timer */ 564 556 557 + 558 + /* 559 + * FIC / OpenMoko, Inc. http://wiki.openmoko.org/wiki/Neo1973_Debug_Board_v3 560 + * Submitted by Harald Welte <laforge@openmoko.org> 561 + */ 562 + #define FIC_VID 0x1457 563 + #define FIC_NEO1973_DEBUG_PID 0x5118 565 564 566 565 /* 567 566 * BmRequestType: 1100 0000b
+12 -5
drivers/usb/serial/garmin_gps.c
··· 1020 1020 if (!serial) 1021 1021 return; 1022 1022 1023 - garmin_clear(garmin_data_p); 1023 + mutex_lock(&port->serial->disc_mutex); 1024 + if (!port->serial->disconnected) 1025 + garmin_clear(garmin_data_p); 1024 1026 1025 1027 /* shutdown our urbs */ 1026 1028 usb_kill_urb (port->read_urb); 1027 1029 usb_kill_urb (port->write_urb); 1028 1030 1029 - if (noResponseFromAppLayer(garmin_data_p) || 1030 - ((garmin_data_p->flags & CLEAR_HALT_REQUIRED) != 0)) { 1031 - process_resetdev_request(port); 1032 - garmin_data_p->state = STATE_RESET; 1031 + if (!port->serial->disconnected) { 1032 + if (noResponseFromAppLayer(garmin_data_p) || 1033 + ((garmin_data_p->flags & CLEAR_HALT_REQUIRED) != 0)) { 1034 + process_resetdev_request(port); 1035 + garmin_data_p->state = STATE_RESET; 1036 + } else { 1037 + garmin_data_p->state = STATE_DISCONNECTED; 1038 + } 1033 1039 } else { 1034 1040 garmin_data_p->state = STATE_DISCONNECTED; 1035 1041 } 1042 + mutex_unlock(&port->serial->disc_mutex); 1036 1043 } 1037 1044 1038 1045
+8
drivers/usb/serial/generic.c
··· 175 175 struct usb_serial_port *port; 176 176 int i, c = 0, r; 177 177 178 + #ifdef CONFIG_PM 179 + /* 180 + * If this is an autoresume, don't submit URBs. 181 + * They will be submitted in the open function instead. 182 + */ 183 + if (serial->dev->auto_pm) 184 + return 0; 185 + #endif 178 186 for (i = 0; i < serial->num_ports; i++) { 179 187 port = serial->port[i]; 180 188 if (port->open_count && port->read_urb) {
+4 -4
drivers/usb/serial/io_edgeport.c
··· 959 959 * 960 960 * This function will block the close until one of the following: 961 961 * 1. Response to our Chase comes from Edgeport 962 - * 2. A timout of 10 seconds without activity has expired 962 + * 2. A timeout of 10 seconds without activity has expired 963 963 * (1K of Edgeport data @ 2400 baud ==> 4 sec to empty) 964 964 * 965 965 ************************************************************************/ ··· 999 999 return; 1000 1000 } 1001 1001 } else { 1002 - // Reset timout value back to 10 seconds 1002 + // Reset timeout value back to 10 seconds 1003 1003 dbg("%s - Last %d, Current %d", __FUNCTION__, lastCredits, edge_port->txCredits); 1004 1004 loop = 10; 1005 1005 } ··· 1014 1014 * This function will block the close until one of the following: 1015 1015 * 1. TX count are 0 1016 1016 * 2. The edgeport has stopped 1017 - * 3. A timout of 3 seconds without activity has expired 1017 + * 3. A timeout of 3 seconds without activity has expired 1018 1018 * 1019 1019 ************************************************************************/ 1020 1020 static void block_until_tx_empty (struct edgeport_port *edge_port) ··· 1050 1050 return; 1051 1051 } 1052 1052 } else { 1053 - // Reset timout value back to seconds 1053 + // Reset timeout value back to seconds 1054 1054 loop = 30; 1055 1055 } 1056 1056 }
+21 -26
drivers/usb/serial/io_ti.c
··· 34 34 #include <linux/tty_flip.h> 35 35 #include <linux/module.h> 36 36 #include <linux/spinlock.h> 37 + #include <linux/mutex.h> 37 38 #include <linux/serial.h> 38 39 #include <linux/ioctl.h> 39 40 #include <asm/uaccess.h> ··· 134 133 struct product_info product_info; 135 134 u8 TI_I2C_Type; // Type of I2C in UMP 136 135 u8 TiReadI2C; // Set to TRUE if we have read the I2c in Boot Mode 137 - struct semaphore es_sem; 136 + struct mutex es_lock; 138 137 int num_ports_open; 139 138 struct usb_serial *serial; 140 139 }; ··· 1979 1978 } 1980 1979 1981 1980 /* set up the port settings */ 1982 - edge_set_termios (port, NULL); 1981 + edge_set_termios (port, port->tty->termios); 1983 1982 1984 1983 /* open up the port */ 1985 1984 ··· 2045 2044 dbg ("ShadowMCR 0x%X", edge_port->shadow_mcr); 2046 2045 2047 2046 edge_serial = edge_port->edge_serial; 2048 - if (down_interruptible(&edge_serial->es_sem)) 2047 + if (mutex_lock_interruptible(&edge_serial->es_lock)) 2049 2048 return -ERESTARTSYS; 2050 2049 if (edge_serial->num_ports_open == 0) { 2051 2050 /* we are the first port to be opened, let's post the interrupt urb */ ··· 2053 2052 if (!urb) { 2054 2053 dev_err (&port->dev, "%s - no interrupt urb present, exiting\n", __FUNCTION__); 2055 2054 status = -EINVAL; 2056 - goto up_es_sem; 2055 + goto release_es_lock; 2057 2056 } 2058 2057 urb->complete = edge_interrupt_callback; 2059 2058 urb->context = edge_serial; ··· 2061 2060 status = usb_submit_urb (urb, GFP_KERNEL); 2062 2061 if (status) { 2063 2062 dev_err (&port->dev, "%s - usb_submit_urb failed with value %d\n", __FUNCTION__, status); 2064 - goto up_es_sem; 2063 + goto release_es_lock; 2065 2064 } 2066 2065 } 2067 2066 ··· 2093 2092 2094 2093 dbg("%s - exited", __FUNCTION__); 2095 2094 2096 - goto up_es_sem; 2095 + goto release_es_lock; 2097 2096 2098 2097 unlink_int_urb: 2099 2098 if (edge_port->edge_serial->num_ports_open == 0) 2100 2099 usb_kill_urb(port->serial->port[0]->interrupt_in_urb); 2101 - up_es_sem: 2102 - up(&edge_serial->es_sem); 2100 + release_es_lock: 2101 + mutex_unlock(&edge_serial->es_lock); 2103 2102 return status; 2104 2103 } 2105 2104 ··· 2138 2137 0, 2139 2138 NULL, 2140 2139 0); 2141 - down(&edge_serial->es_sem); 2140 + mutex_lock(&edge_serial->es_lock); 2142 2141 --edge_port->edge_serial->num_ports_open; 2143 2142 if (edge_port->edge_serial->num_ports_open <= 0) { 2144 2143 /* last port is now closed, let's shut down our interrupt urb */ 2145 2144 usb_kill_urb(port->serial->port[0]->interrupt_in_urb); 2146 2145 edge_port->edge_serial->num_ports_open = 0; 2147 2146 } 2148 - up(&edge_serial->es_sem); 2147 + mutex_unlock(&edge_serial->es_lock); 2149 2148 edge_port->close_pending = 0; 2150 2149 2151 2150 dbg("%s - exited", __FUNCTION__); ··· 2394 2393 dbg("%s - port %d", __FUNCTION__, edge_port->port->number); 2395 2394 2396 2395 tty = edge_port->port->tty; 2397 - if ((!tty) || 2398 - (!tty->termios)) { 2399 - dbg("%s - no tty structures", __FUNCTION__); 2400 - return; 2401 - } 2402 2396 2403 2397 config = kmalloc (sizeof (*config), GFP_KERNEL); 2404 2398 if (!config) { ··· 2488 2492 } 2489 2493 } 2490 2494 2495 + tty->termios->c_cflag &= ~CMSPAR; 2496 + 2491 2497 /* Round the baud rate */ 2492 2498 baud = tty_get_baud_rate(tty); 2493 2499 if (!baud) { 2494 2500 /* pick a default, any default... */ 2495 2501 baud = 9600; 2496 - } 2502 + } else 2503 + tty_encode_baud_rate(tty, baud, baud); 2504 + 2497 2505 edge_port->baud_rate = baud; 2498 2506 config->wBaudRate = (__u16)((461550L + baud/2) / baud); 2507 + 2508 + /* FIXME: Recompute actual baud from divisor here */ 2499 2509 2500 2510 dbg ("%s - baud rate = %d, wBaudRate = %d", __FUNCTION__, baud, config->wBaudRate); 2501 2511 ··· 2540 2538 struct tty_struct *tty = port->tty; 2541 2539 unsigned int cflag; 2542 2540 2543 - if (!port->tty || !port->tty->termios) { 2544 - dbg ("%s - no tty or termios", __FUNCTION__); 2545 - return; 2546 - } 2547 - 2548 2541 cflag = tty->termios->c_cflag; 2549 2542 2550 2543 dbg("%s - clfag %08x iflag %08x", __FUNCTION__, 2551 2544 tty->termios->c_cflag, tty->termios->c_iflag); 2552 - if (old_termios) { 2553 - dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__, 2554 - old_termios->c_cflag, old_termios->c_iflag); 2555 - } 2545 + dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__, 2546 + old_termios->c_cflag, old_termios->c_iflag); 2556 2547 2557 2548 dbg("%s - port %d", __FUNCTION__, port->number); 2558 2549 ··· 2738 2743 dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__); 2739 2744 return -ENOMEM; 2740 2745 } 2741 - sema_init(&edge_serial->es_sem, 1); 2746 + mutex_init(&edge_serial->es_lock); 2742 2747 edge_serial->serial = serial; 2743 2748 usb_set_serial_data(serial, edge_serial); 2744 2749
+1217
drivers/usb/serial/iuu_phoenix.c
··· 1 + /* 2 + * Infinity Unlimited USB Phoenix driver 3 + * 4 + * Copyright (C) 2007 Alain Degreffe (eczema@ecze.com) 5 + * 6 + * Original code taken from iuutool (Copyright (C) 2006 Juan Carlos Borrás) 7 + * 8 + * This program is free software; you can redistribute it and/or modify 9 + * it under the terms of the GNU General Public License as published by 10 + * the Free Software Foundation; either version 2 of the License, or 11 + * (at your option) any later version. 12 + * 13 + * And tested with help of WB Electronics 14 + * 15 + */ 16 + #include <linux/kernel.h> 17 + #include <linux/errno.h> 18 + #include <linux/init.h> 19 + #include <linux/slab.h> 20 + #include <linux/tty.h> 21 + #include <linux/tty_driver.h> 22 + #include <linux/tty_flip.h> 23 + #include <linux/serial.h> 24 + #include <linux/module.h> 25 + #include <linux/moduleparam.h> 26 + #include <linux/spinlock.h> 27 + #include <linux/uaccess.h> 28 + #include <linux/usb.h> 29 + #include <linux/usb/serial.h> 30 + #include "iuu_phoenix.h" 31 + #include <linux/random.h> 32 + 33 + 34 + #ifdef CONFIG_USB_SERIAL_DEBUG 35 + static int debug = 1; 36 + #else 37 + static int debug; 38 + #endif 39 + 40 + /* 41 + * Version Information 42 + */ 43 + #define DRIVER_VERSION "v0.5" 44 + #define DRIVER_DESC "Infinity USB Unlimited Phoenix driver" 45 + 46 + static struct usb_device_id id_table[] = { 47 + {USB_DEVICE(IUU_USB_VENDOR_ID, IUU_USB_PRODUCT_ID)}, 48 + {} /* Terminating entry */ 49 + }; 50 + MODULE_DEVICE_TABLE(usb, id_table); 51 + 52 + static struct usb_driver iuu_driver = { 53 + .name = "iuu_phoenix", 54 + .probe = usb_serial_probe, 55 + .disconnect = usb_serial_disconnect, 56 + .id_table = id_table, 57 + .no_dynamic_id = 1, 58 + }; 59 + 60 + /* turbo parameter */ 61 + static int boost = 100; 62 + static int clockmode = 1; 63 + static int cdmode = 1; 64 + static int iuu_cardin; 65 + static int iuu_cardout; 66 + static int xmas; 67 + 68 + static void read_rxcmd_callback(struct urb *urb); 69 + 70 + struct iuu_private { 71 + spinlock_t lock; /* store irq state */ 72 + wait_queue_head_t delta_msr_wait; 73 + u8 line_control; 74 + u8 line_status; 75 + u8 termios_initialized; 76 + int tiostatus; /* store IUART SIGNAL for tiocmget call */ 77 + u8 reset; /* if 1 reset is needed */ 78 + int poll; /* number of poll */ 79 + u8 *writebuf; /* buffer for writing to device */ 80 + int writelen; /* num of byte to write to device */ 81 + u8 *buf; /* used for initialize speed */ 82 + u8 *dbgbuf; /* debug buffer */ 83 + u8 len; 84 + }; 85 + 86 + 87 + static void iuu_free_buf(struct iuu_private *priv) 88 + { 89 + kfree(priv->buf); 90 + kfree(priv->dbgbuf); 91 + kfree(priv->writebuf); 92 + } 93 + 94 + static int iuu_alloc_buf(struct iuu_private *priv) 95 + { 96 + priv->buf = kzalloc(256, GFP_KERNEL); 97 + priv->dbgbuf = kzalloc(256, GFP_KERNEL); 98 + priv->writebuf = kzalloc(256, GFP_KERNEL); 99 + if (!priv->buf || !priv->dbgbuf || !priv->writebuf) { 100 + iuu_free_buf(priv); 101 + dbg("%s problem allocation buffer", __FUNCTION__); 102 + return -ENOMEM; 103 + } 104 + dbg("%s - Privates buffers allocation success", __FUNCTION__); 105 + return 0; 106 + } 107 + 108 + static int iuu_startup(struct usb_serial *serial) 109 + { 110 + struct iuu_private *priv; 111 + priv = kzalloc(sizeof(struct iuu_private), GFP_KERNEL); 112 + dbg("%s- priv allocation success", __FUNCTION__); 113 + if (!priv) 114 + return -ENOMEM; 115 + if (iuu_alloc_buf(priv)) { 116 + kfree(priv); 117 + return -ENOMEM; 118 + } 119 + spin_lock_init(&priv->lock); 120 + init_waitqueue_head(&priv->delta_msr_wait); 121 + usb_set_serial_port_data(serial->port[0], priv); 122 + return 0; 123 + } 124 + 125 + /* Shutdown function */ 126 + static void iuu_shutdown(struct usb_serial *serial) 127 + { 128 + struct usb_serial_port *port = serial->port[0]; 129 + struct iuu_private *priv = usb_get_serial_port_data(port); 130 + if (!port) 131 + return; 132 + 133 + dbg("%s", __FUNCTION__); 134 + 135 + if (priv) { 136 + iuu_free_buf(priv); 137 + dbg("%s - I will free all", __FUNCTION__); 138 + usb_set_serial_port_data(port, NULL); 139 + 140 + dbg("%s - priv is not anymore in port structure", __FUNCTION__); 141 + kfree(priv); 142 + 143 + dbg("%s priv is now kfree", __FUNCTION__); 144 + } 145 + } 146 + 147 + static int iuu_tiocmset(struct usb_serial_port *port, struct file *file, 148 + unsigned int set, unsigned int clear) 149 + { 150 + struct iuu_private *priv = usb_get_serial_port_data(port); 151 + struct tty_struct *tty; 152 + tty = port->tty; 153 + 154 + dbg("%s (%d) msg : SET = 0x%04x, CLEAR = 0x%04x ", __FUNCTION__, 155 + port->number, set, clear); 156 + if (set & TIOCM_RTS) 157 + priv->tiostatus = TIOCM_RTS; 158 + 159 + if (!(set & TIOCM_RTS) && priv->tiostatus == TIOCM_RTS) { 160 + dbg("%s TIOCMSET RESET called !!!", __FUNCTION__); 161 + priv->reset = 1; 162 + return 0; 163 + } 164 + 165 + return 0; 166 + } 167 + 168 + /* This is used to provide a carrier detect mechanism 169 + * When a card is present, the response is 0x00 170 + * When no card , the reader respond with TIOCM_CD 171 + * This is known as CD autodetect mechanism 172 + */ 173 + static int iuu_tiocmget(struct usb_serial_port *port, struct file *file) 174 + { 175 + struct iuu_private *priv = usb_get_serial_port_data(port); 176 + return priv->tiostatus; 177 + } 178 + 179 + static void iuu_rxcmd(struct urb *urb) 180 + { 181 + struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 182 + int result; 183 + dbg("%s - enter", __FUNCTION__); 184 + 185 + if (urb->status) { 186 + dbg("%s - urb->status = %d", __FUNCTION__, urb->status); 187 + /* error stop all */ 188 + return; 189 + } 190 + 191 + 192 + memset(port->write_urb->transfer_buffer, IUU_UART_RX, 1); 193 + usb_fill_bulk_urb(port->write_urb, port->serial->dev, 194 + usb_sndbulkpipe(port->serial->dev, 195 + port->bulk_out_endpointAddress), 196 + port->write_urb->transfer_buffer, 1, 197 + read_rxcmd_callback, port); 198 + result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 199 + } 200 + 201 + static int iuu_reset(struct usb_serial_port *port, u8 wt) 202 + { 203 + struct iuu_private *priv = usb_get_serial_port_data(port); 204 + int result; 205 + char *buf_ptr = port->write_urb->transfer_buffer; 206 + dbg("%s - enter", __FUNCTION__); 207 + 208 + /* Prepare the reset sequence */ 209 + 210 + *buf_ptr++ = IUU_RST_SET; 211 + *buf_ptr++ = IUU_DELAY_MS; 212 + *buf_ptr++ = wt; 213 + *buf_ptr = IUU_RST_CLEAR; 214 + 215 + /* send the sequence */ 216 + 217 + usb_fill_bulk_urb(port->write_urb, 218 + port->serial->dev, 219 + usb_sndbulkpipe(port->serial->dev, 220 + port->bulk_out_endpointAddress), 221 + port->write_urb->transfer_buffer, 4, iuu_rxcmd, port); 222 + result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 223 + priv->reset = 0; 224 + return result; 225 + } 226 + 227 + /* Status Function 228 + * Return value is 229 + * 0x00 = no card 230 + * 0x01 = smartcard 231 + * 0x02 = sim card 232 + */ 233 + static void iuu_update_status_callback(struct urb *urb) 234 + { 235 + struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 236 + struct iuu_private *priv = usb_get_serial_port_data(port); 237 + u8 *st; 238 + dbg("%s - enter", __FUNCTION__); 239 + 240 + if (urb->status) { 241 + dbg("%s - urb->status = %d", __FUNCTION__, urb->status); 242 + /* error stop all */ 243 + return; 244 + } 245 + 246 + st = urb->transfer_buffer; 247 + dbg("%s - enter", __FUNCTION__); 248 + if (urb->actual_length == 1) { 249 + switch (st[0]) { 250 + case 0x1: 251 + priv->tiostatus = iuu_cardout; 252 + break; 253 + case 0x0: 254 + priv->tiostatus = iuu_cardin; 255 + break; 256 + default: 257 + priv->tiostatus = iuu_cardin; 258 + } 259 + } 260 + iuu_rxcmd(urb); 261 + } 262 + 263 + static void iuu_status_callback(struct urb *urb) 264 + { 265 + struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 266 + int result; 267 + dbg("%s - enter", __FUNCTION__); 268 + 269 + dbg("%s - urb->status = %d", __FUNCTION__, urb->status); 270 + usb_fill_bulk_urb(port->read_urb, port->serial->dev, 271 + usb_rcvbulkpipe(port->serial->dev, 272 + port->bulk_in_endpointAddress), 273 + port->read_urb->transfer_buffer, 256, 274 + iuu_update_status_callback, port); 275 + result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 276 + } 277 + 278 + static int iuu_status(struct usb_serial_port *port) 279 + { 280 + int result; 281 + 282 + dbg("%s - enter", __FUNCTION__); 283 + 284 + memset(port->write_urb->transfer_buffer, IUU_GET_STATE_REGISTER, 1); 285 + usb_fill_bulk_urb(port->write_urb, port->serial->dev, 286 + usb_sndbulkpipe(port->serial->dev, 287 + port->bulk_out_endpointAddress), 288 + port->write_urb->transfer_buffer, 1, 289 + iuu_status_callback, port); 290 + result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 291 + return result; 292 + 293 + } 294 + 295 + static int bulk_immediate(struct usb_serial_port *port, u8 *buf, u8 count) 296 + { 297 + int status; 298 + struct usb_serial *serial = port->serial; 299 + int actual = 0; 300 + 301 + dbg("%s - enter", __FUNCTION__); 302 + 303 + /* send the data out the bulk port */ 304 + 305 + status = 306 + usb_bulk_msg(serial->dev, 307 + usb_sndbulkpipe(serial->dev, 308 + port->bulk_out_endpointAddress), buf, 309 + count, &actual, HZ * 1); 310 + 311 + if (status != IUU_OPERATION_OK) { 312 + dbg("%s - error = %2x", __FUNCTION__, status); 313 + } else { 314 + dbg("%s - write OK !", __FUNCTION__); 315 + } 316 + return status; 317 + } 318 + 319 + static int read_immediate(struct usb_serial_port *port, u8 *buf, u8 count) 320 + { 321 + int status; 322 + struct usb_serial *serial = port->serial; 323 + int actual = 0; 324 + 325 + dbg("%s - enter", __FUNCTION__); 326 + 327 + /* send the data out the bulk port */ 328 + 329 + status = 330 + usb_bulk_msg(serial->dev, 331 + usb_rcvbulkpipe(serial->dev, 332 + port->bulk_in_endpointAddress), buf, 333 + count, &actual, HZ * 1); 334 + 335 + if (status != IUU_OPERATION_OK) { 336 + dbg("%s - error = %2x", __FUNCTION__, status); 337 + } else { 338 + dbg("%s - read OK !", __FUNCTION__); 339 + } 340 + 341 + return status; 342 + } 343 + 344 + static int iuu_led(struct usb_serial_port *port, unsigned int R, 345 + unsigned int G, unsigned int B, u8 f) 346 + { 347 + int status; 348 + u8 *buf; 349 + buf = kmalloc(8, GFP_KERNEL); 350 + if (!buf) 351 + return -ENOMEM; 352 + 353 + dbg("%s - enter", __FUNCTION__); 354 + 355 + buf[0] = IUU_SET_LED; 356 + buf[1] = R & 0xFF; 357 + buf[2] = (R >> 8) & 0xFF; 358 + buf[3] = G & 0xFF; 359 + buf[4] = (G >> 8) & 0xFF; 360 + buf[5] = B & 0xFF; 361 + buf[6] = (B >> 8) & 0xFF; 362 + buf[7] = f; 363 + status = bulk_immediate(port, buf, 8); 364 + kfree(buf); 365 + if (status != IUU_OPERATION_OK) 366 + dbg("%s - led error status = %2x", __FUNCTION__, status); 367 + else 368 + dbg("%s - led OK !", __FUNCTION__); 369 + return IUU_OPERATION_OK; 370 + } 371 + 372 + static void iuu_rgbf_fill_buffer(u8 *buf, u8 r1, u8 r2, u8 g1, u8 g2, u8 b1, 373 + u8 b2, u8 freq) 374 + { 375 + *buf++ = IUU_SET_LED; 376 + *buf++ = r1; 377 + *buf++ = r2; 378 + *buf++ = g1; 379 + *buf++ = g2; 380 + *buf++ = b1; 381 + *buf++ = b2; 382 + *buf = freq; 383 + } 384 + 385 + static void iuu_led_activity_on(struct urb *urb) 386 + { 387 + struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 388 + int result; 389 + char *buf_ptr = port->write_urb->transfer_buffer; 390 + *buf_ptr++ = IUU_SET_LED; 391 + if (xmas == 1) { 392 + get_random_bytes(buf_ptr, 6); 393 + *(buf_ptr+7) = 1; 394 + } else { 395 + iuu_rgbf_fill_buffer(buf_ptr, 255, 255, 0, 0, 0, 0, 255); 396 + } 397 + 398 + usb_fill_bulk_urb(port->write_urb, port->serial->dev, 399 + usb_sndbulkpipe(port->serial->dev, 400 + port->bulk_out_endpointAddress), 401 + port->write_urb->transfer_buffer, 8 , 402 + iuu_rxcmd, port); 403 + result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 404 + } 405 + 406 + static void iuu_led_activity_off(struct urb *urb) 407 + { 408 + struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 409 + int result; 410 + char *buf_ptr = port->write_urb->transfer_buffer; 411 + if (xmas == 1) { 412 + iuu_rxcmd(urb); 413 + return; 414 + } else { 415 + *buf_ptr++ = IUU_SET_LED; 416 + iuu_rgbf_fill_buffer(buf_ptr, 0, 0, 255, 255, 0, 0, 255); 417 + } 418 + usb_fill_bulk_urb(port->write_urb, port->serial->dev, 419 + usb_sndbulkpipe(port->serial->dev, 420 + port->bulk_out_endpointAddress), 421 + port->write_urb->transfer_buffer, 8 , 422 + iuu_rxcmd, port); 423 + result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 424 + } 425 + 426 + 427 + 428 + static int iuu_clk(struct usb_serial_port *port, int dwFrq) 429 + { 430 + int status; 431 + struct iuu_private *priv = usb_get_serial_port_data(port); 432 + int Count = 0; 433 + u8 FrqGenAdr = 0x69; 434 + u8 DIV = 0; /* 8bit */ 435 + u8 XDRV = 0; /* 8bit */ 436 + u8 PUMP = 0; /* 3bit */ 437 + u8 PBmsb = 0; /* 2bit */ 438 + u8 PBlsb = 0; /* 8bit */ 439 + u8 PO = 0; /* 1bit */ 440 + u8 Q = 0; /* 7bit */ 441 + /* 24bit = 3bytes */ 442 + unsigned int P = 0; 443 + unsigned int P2 = 0; 444 + int frq = (int)dwFrq; 445 + 446 + dbg("%s - enter", __FUNCTION__); 447 + 448 + if (frq == 0) { 449 + priv->buf[Count++] = IUU_UART_WRITE_I2C; 450 + priv->buf[Count++] = FrqGenAdr << 1; 451 + priv->buf[Count++] = 0x09; 452 + priv->buf[Count++] = 0x00; 453 + 454 + status = bulk_immediate(port, (u8 *) priv->buf, Count); 455 + if (status != 0) { 456 + dbg("%s - write error ", __FUNCTION__); 457 + return status; 458 + } 459 + } else if (frq == 3579000) { 460 + DIV = 100; 461 + P = 1193; 462 + Q = 40; 463 + XDRV = 0; 464 + } else if (frq == 3680000) { 465 + DIV = 105; 466 + P = 161; 467 + Q = 5; 468 + XDRV = 0; 469 + } else if (frq == 6000000) { 470 + DIV = 66; 471 + P = 66; 472 + Q = 2; 473 + XDRV = 0x28; 474 + } else { 475 + unsigned int result = 0; 476 + unsigned int tmp = 0; 477 + unsigned int check; 478 + unsigned int check2; 479 + char found = 0x00; 480 + unsigned int lQ = 2; 481 + unsigned int lP = 2055; 482 + unsigned int lDiv = 4; 483 + 484 + for (lQ = 2; lQ <= 47 && !found; lQ++) 485 + for (lP = 2055; lP >= 8 && !found; lP--) 486 + for (lDiv = 4; lDiv <= 127 && !found; lDiv++) { 487 + tmp = (12000000 / lDiv) * (lP / lQ); 488 + if (abs((int)(tmp - frq)) < 489 + abs((int)(frq - result))) { 490 + check2 = (12000000 / lQ); 491 + if (check2 < 250000) 492 + continue; 493 + check = (12000000 / lQ) * lP; 494 + if (check > 400000000) 495 + continue; 496 + if (check < 100000000) 497 + continue; 498 + if (lDiv < 4 || lDiv > 127) 499 + continue; 500 + result = tmp; 501 + P = lP; 502 + DIV = lDiv; 503 + Q = lQ; 504 + if (result == frq) 505 + found = 0x01; 506 + } 507 + } 508 + } 509 + P2 = ((P - PO) / 2) - 4; 510 + DIV = DIV; 511 + PUMP = 0x04; 512 + PBmsb = (P2 >> 8 & 0x03); 513 + PBlsb = P2 & 0xFF; 514 + PO = (P >> 10) & 0x01; 515 + Q = Q - 2; 516 + 517 + priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ 518 + priv->buf[Count++] = FrqGenAdr << 1; 519 + priv->buf[Count++] = 0x09; 520 + priv->buf[Count++] = 0x20; /* Adr = 0x09 */ 521 + priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ 522 + priv->buf[Count++] = FrqGenAdr << 1; 523 + priv->buf[Count++] = 0x0C; 524 + priv->buf[Count++] = DIV; /* Adr = 0x0C */ 525 + priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ 526 + priv->buf[Count++] = FrqGenAdr << 1; 527 + priv->buf[Count++] = 0x12; 528 + priv->buf[Count++] = XDRV; /* Adr = 0x12 */ 529 + priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ 530 + priv->buf[Count++] = FrqGenAdr << 1; 531 + priv->buf[Count++] = 0x13; 532 + priv->buf[Count++] = 0x6B; /* Adr = 0x13 */ 533 + priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ 534 + priv->buf[Count++] = FrqGenAdr << 1; 535 + priv->buf[Count++] = 0x40; 536 + priv->buf[Count++] = (0xC0 | ((PUMP & 0x07) << 2)) | 537 + (PBmsb & 0x03); /* Adr = 0x40 */ 538 + priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ 539 + priv->buf[Count++] = FrqGenAdr << 1; 540 + priv->buf[Count++] = 0x41; 541 + priv->buf[Count++] = PBlsb; /* Adr = 0x41 */ 542 + priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ 543 + priv->buf[Count++] = FrqGenAdr << 1; 544 + priv->buf[Count++] = 0x42; 545 + priv->buf[Count++] = Q | (((PO & 0x01) << 7)); /* Adr = 0x42 */ 546 + priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ 547 + priv->buf[Count++] = FrqGenAdr << 1; 548 + priv->buf[Count++] = 0x44; 549 + priv->buf[Count++] = (char)0xFF; /* Adr = 0x44 */ 550 + priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ 551 + priv->buf[Count++] = FrqGenAdr << 1; 552 + priv->buf[Count++] = 0x45; 553 + priv->buf[Count++] = (char)0xFE; /* Adr = 0x45 */ 554 + priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ 555 + priv->buf[Count++] = FrqGenAdr << 1; 556 + priv->buf[Count++] = 0x46; 557 + priv->buf[Count++] = 0x7F; /* Adr = 0x46 */ 558 + priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */ 559 + priv->buf[Count++] = FrqGenAdr << 1; 560 + priv->buf[Count++] = 0x47; 561 + priv->buf[Count++] = (char)0x84; /* Adr = 0x47 */ 562 + 563 + status = bulk_immediate(port, (u8 *) priv->buf, Count); 564 + if (status != IUU_OPERATION_OK) 565 + dbg("%s - write error ", __FUNCTION__); 566 + return status; 567 + } 568 + 569 + static int iuu_uart_flush(struct usb_serial_port *port) 570 + { 571 + int i; 572 + int status; 573 + u8 rxcmd = IUU_UART_RX; 574 + struct iuu_private *priv = usb_get_serial_port_data(port); 575 + 576 + dbg("%s - enter", __FUNCTION__); 577 + 578 + if (iuu_led(port, 0xF000, 0, 0, 0xFF) < 0) 579 + return -EIO; 580 + 581 + for (i = 0; i < 2; i++) { 582 + status = bulk_immediate(port, &rxcmd, 1); 583 + if (status != IUU_OPERATION_OK) { 584 + dbg("%s - uart_flush_write error", __FUNCTION__); 585 + return status; 586 + } 587 + 588 + status = read_immediate(port, &priv->len, 1); 589 + if (status != IUU_OPERATION_OK) { 590 + dbg("%s - uart_flush_read error", __FUNCTION__); 591 + return status; 592 + } 593 + 594 + if (priv->len > 0) { 595 + dbg("%s - uart_flush datalen is : %i ", __FUNCTION__, 596 + priv->len); 597 + status = read_immediate(port, priv->buf, priv->len); 598 + if (status != IUU_OPERATION_OK) { 599 + dbg("%s - uart_flush_read error", __FUNCTION__); 600 + return status; 601 + } 602 + } 603 + } 604 + dbg("%s - uart_flush_read OK!", __FUNCTION__); 605 + iuu_led(port, 0, 0xF000, 0, 0xFF); 606 + return status; 607 + } 608 + 609 + static void read_buf_callback(struct urb *urb) 610 + { 611 + struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 612 + unsigned char *data = urb->transfer_buffer; 613 + struct tty_struct *tty; 614 + dbg("%s - urb->status = %d", __FUNCTION__, urb->status); 615 + 616 + if (urb->status) { 617 + dbg("%s - urb->status = %d", __FUNCTION__, urb->status); 618 + if (urb->status == -EPROTO) { 619 + /* reschedule needed */ 620 + } 621 + return; 622 + } 623 + 624 + dbg("%s - %i chars to write", __FUNCTION__, urb->actual_length); 625 + tty = port->tty; 626 + if (data == NULL) 627 + dbg("%s - data is NULL !!!", __FUNCTION__); 628 + if (tty && urb->actual_length && data) { 629 + tty_insert_flip_string(tty, data, urb->actual_length); 630 + tty_flip_buffer_push(tty); 631 + } 632 + iuu_led_activity_on(urb); 633 + } 634 + 635 + static int iuu_bulk_write(struct usb_serial_port *port) 636 + { 637 + struct iuu_private *priv = usb_get_serial_port_data(port); 638 + unsigned int flags; 639 + int result; 640 + int i; 641 + char *buf_ptr = port->write_urb->transfer_buffer; 642 + dbg("%s - enter", __FUNCTION__); 643 + 644 + *buf_ptr++ = IUU_UART_ESC; 645 + *buf_ptr++ = IUU_UART_TX; 646 + *buf_ptr++ = priv->writelen; 647 + 648 + memcpy(buf_ptr, priv->writebuf, 649 + priv->writelen); 650 + if (debug == 1) { 651 + for (i = 0; i < priv->writelen; i++) 652 + sprintf(priv->dbgbuf + i*2 , 653 + "%02X", priv->writebuf[i]); 654 + priv->dbgbuf[priv->writelen+i*2] = 0; 655 + dbg("%s - writing %i chars : %s", __FUNCTION__, 656 + priv->writelen, priv->dbgbuf); 657 + } 658 + usb_fill_bulk_urb(port->write_urb, port->serial->dev, 659 + usb_sndbulkpipe(port->serial->dev, 660 + port->bulk_out_endpointAddress), 661 + port->write_urb->transfer_buffer, priv->writelen + 3, 662 + iuu_rxcmd, port); 663 + result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 664 + spin_lock_irqsave(&priv->lock, flags); 665 + priv->writelen = 0; 666 + spin_unlock_irqrestore(&priv->lock, flags); 667 + usb_serial_port_softint(port); 668 + return result; 669 + } 670 + 671 + static int iuu_read_buf(struct usb_serial_port *port, int len) 672 + { 673 + int result; 674 + dbg("%s - enter", __FUNCTION__); 675 + 676 + usb_fill_bulk_urb(port->read_urb, port->serial->dev, 677 + usb_rcvbulkpipe(port->serial->dev, 678 + port->bulk_in_endpointAddress), 679 + port->read_urb->transfer_buffer, len, 680 + read_buf_callback, port); 681 + result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 682 + return result; 683 + } 684 + 685 + static void iuu_uart_read_callback(struct urb *urb) 686 + { 687 + struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 688 + struct iuu_private *priv = usb_get_serial_port_data(port); 689 + unsigned int flags; 690 + int status; 691 + int error = 0; 692 + int len = 0; 693 + unsigned char *data = urb->transfer_buffer; 694 + priv->poll++; 695 + 696 + dbg("%s - enter", __FUNCTION__); 697 + 698 + if (urb->status) { 699 + dbg("%s - urb->status = %d", __FUNCTION__, urb->status); 700 + /* error stop all */ 701 + return; 702 + } 703 + if (data == NULL) 704 + dbg("%s - data is NULL !!!", __FUNCTION__); 705 + 706 + if (urb->actual_length == 1 && data != NULL) 707 + len = (int) data[0]; 708 + 709 + if (urb->actual_length > 1) { 710 + dbg("%s - urb->actual_length = %i", __FUNCTION__, 711 + urb->actual_length); 712 + error = 1; 713 + return; 714 + } 715 + /* if len > 0 call readbuf */ 716 + 717 + if (len > 0 && error == 0) { 718 + dbg("%s - call read buf - len to read is %i ", 719 + __FUNCTION__, len); 720 + status = iuu_read_buf(port, len); 721 + return; 722 + } 723 + /* need to update status ? */ 724 + if (priv->poll > 99) { 725 + status = iuu_status(port); 726 + priv->poll = 0; 727 + return; 728 + } 729 + 730 + /* reset waiting ? */ 731 + 732 + if (priv->reset == 1) { 733 + status = iuu_reset(port, 0xC); 734 + return; 735 + } 736 + /* Writebuf is waiting */ 737 + spin_lock_irqsave(&priv->lock, flags); 738 + if (priv->writelen > 0) { 739 + spin_unlock_irqrestore(&priv->lock, flags); 740 + status = iuu_bulk_write(port); 741 + return; 742 + } 743 + spin_unlock_irqrestore(&priv->lock, flags); 744 + /* if nothing to write call again rxcmd */ 745 + dbg("%s - rxcmd recall", __FUNCTION__); 746 + iuu_led_activity_off(urb); 747 + return; 748 + } 749 + 750 + static int iuu_uart_write(struct usb_serial_port *port, const u8 *buf, 751 + int count) 752 + { 753 + struct iuu_private *priv = usb_get_serial_port_data(port); 754 + unsigned int flags; 755 + dbg("%s - enter", __FUNCTION__); 756 + 757 + if (count > 256) 758 + return -ENOMEM; 759 + 760 + spin_lock_irqsave(&priv->lock, flags); 761 + if (priv->writelen > 0) { 762 + /* buffer already filled but not commited */ 763 + spin_unlock_irqrestore(&priv->lock, flags); 764 + return (0); 765 + } 766 + /* fill the buffer */ 767 + memcpy(priv->writebuf, buf, count); 768 + priv->writelen = count; 769 + spin_unlock_irqrestore(&priv->lock, flags); 770 + 771 + return (count); 772 + } 773 + 774 + static void read_rxcmd_callback(struct urb *urb) 775 + { 776 + struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 777 + int result; 778 + dbg("%s - enter", __FUNCTION__); 779 + 780 + dbg("%s - urb->status = %d", __FUNCTION__, urb->status); 781 + 782 + if (urb->status) { 783 + dbg("%s - urb->status = %d", __FUNCTION__, urb->status); 784 + /* error stop all */ 785 + return; 786 + } 787 + 788 + usb_fill_bulk_urb(port->read_urb, port->serial->dev, 789 + usb_rcvbulkpipe(port->serial->dev, 790 + port->bulk_in_endpointAddress), 791 + port->read_urb->transfer_buffer, 256, 792 + iuu_uart_read_callback, port); 793 + result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 794 + dbg("%s - submit result = %d", __FUNCTION__, result); 795 + return; 796 + } 797 + 798 + static int iuu_uart_on(struct usb_serial_port *port) 799 + { 800 + int status; 801 + u8 *buf; 802 + 803 + buf = kmalloc(sizeof(u8) * 4, GFP_KERNEL); 804 + 805 + if (!buf) 806 + return -ENOMEM; 807 + 808 + buf[0] = IUU_UART_ENABLE; 809 + buf[1] = (u8) ((IUU_BAUD_9600 >> 8) & 0x00FF); 810 + buf[2] = (u8) (0x00FF & IUU_BAUD_9600); 811 + buf[3] = (u8) (0x0F0 & IUU_TWO_STOP_BITS) | (0x07 & IUU_PARITY_EVEN); 812 + 813 + status = bulk_immediate(port, buf, 4); 814 + if (status != IUU_OPERATION_OK) { 815 + dbg("%s - uart_on error", __FUNCTION__); 816 + goto uart_enable_failed; 817 + } 818 + /* iuu_reset() the card after iuu_uart_on() */ 819 + status = iuu_uart_flush(port); 820 + if (status != IUU_OPERATION_OK) 821 + dbg("%s - uart_flush error", __FUNCTION__); 822 + uart_enable_failed: 823 + kfree(buf); 824 + return status; 825 + } 826 + 827 + /* Diables the IUU UART (a.k.a. the Phoenix voiderface) */ 828 + static int iuu_uart_off(struct usb_serial_port *port) 829 + { 830 + int status; 831 + u8 *buf; 832 + buf = kmalloc(1, GFP_KERNEL); 833 + if (!buf) 834 + return -ENOMEM; 835 + buf[0] = IUU_UART_DISABLE; 836 + 837 + status = bulk_immediate(port, buf, 1); 838 + if (status != IUU_OPERATION_OK) 839 + dbg("%s - uart_off error", __FUNCTION__); 840 + 841 + kfree(buf); 842 + return status; 843 + } 844 + 845 + static int iuu_uart_baud(struct usb_serial_port *port, u32 baud, 846 + u32 *actual, u8 parity) 847 + { 848 + int status; 849 + u8 *dataout; 850 + u8 DataCount = 0; 851 + u8 T1Frekvens = 0; 852 + u8 T1reload = 0; 853 + unsigned int T1FrekvensHZ = 0; 854 + 855 + dataout = kmalloc(sizeof(u8) * 5, GFP_KERNEL); 856 + 857 + if (!dataout) 858 + return -ENOMEM; 859 + 860 + if (baud < 1200 || baud > 230400) { 861 + kfree(dataout); 862 + return IUU_INVALID_PARAMETER; 863 + } 864 + if (baud > 977) { 865 + T1Frekvens = 3; 866 + T1FrekvensHZ = 500000; 867 + } 868 + 869 + if (baud > 3906) { 870 + T1Frekvens = 2; 871 + T1FrekvensHZ = 2000000; 872 + } 873 + 874 + if (baud > 11718) { 875 + T1Frekvens = 1; 876 + T1FrekvensHZ = 6000000; 877 + } 878 + 879 + if (baud > 46875) { 880 + T1Frekvens = 0; 881 + T1FrekvensHZ = 24000000; 882 + } 883 + 884 + T1reload = 256 - (u8) (T1FrekvensHZ / (baud * 2)); 885 + 886 + /* magic number here: ENTER_FIRMWARE_UPDATE; */ 887 + dataout[DataCount++] = IUU_UART_ESC; 888 + /* magic number here: CHANGE_BAUD; */ 889 + dataout[DataCount++] = IUU_UART_CHANGE; 890 + dataout[DataCount++] = T1Frekvens; 891 + dataout[DataCount++] = T1reload; 892 + 893 + *actual = (T1FrekvensHZ / (256 - T1reload)) / 2; 894 + 895 + switch (parity & 0x0F) { 896 + case IUU_PARITY_NONE: 897 + dataout[DataCount++] = 0x00; 898 + break; 899 + case IUU_PARITY_EVEN: 900 + dataout[DataCount++] = 0x01; 901 + break; 902 + case IUU_PARITY_ODD: 903 + dataout[DataCount++] = 0x02; 904 + break; 905 + case IUU_PARITY_MARK: 906 + dataout[DataCount++] = 0x03; 907 + break; 908 + case IUU_PARITY_SPACE: 909 + dataout[DataCount++] = 0x04; 910 + break; 911 + default: 912 + kfree(dataout); 913 + return IUU_INVALID_PARAMETER; 914 + break; 915 + } 916 + 917 + switch (parity & 0xF0) { 918 + case IUU_ONE_STOP_BIT: 919 + dataout[DataCount - 1] |= IUU_ONE_STOP_BIT; 920 + break; 921 + 922 + case IUU_TWO_STOP_BITS: 923 + dataout[DataCount - 1] |= IUU_TWO_STOP_BITS; 924 + break; 925 + default: 926 + kfree(dataout); 927 + return IUU_INVALID_PARAMETER; 928 + break; 929 + } 930 + 931 + status = bulk_immediate(port, dataout, DataCount); 932 + if (status != IUU_OPERATION_OK) 933 + dbg("%s - uart_off error", __FUNCTION__); 934 + kfree(dataout); 935 + return status; 936 + } 937 + 938 + static int set_control_lines(struct usb_device *dev, u8 value) 939 + { 940 + return 0; 941 + } 942 + 943 + static void iuu_close(struct usb_serial_port *port, struct file *filp) 944 + { 945 + /* iuu_led (port,255,0,0,0); */ 946 + struct usb_serial *serial; 947 + struct iuu_private *priv = usb_get_serial_port_data(port); 948 + unsigned long flags; 949 + unsigned int c_cflag; 950 + 951 + serial = port->serial; 952 + if (!serial) 953 + return; 954 + 955 + dbg("%s - port %d", __FUNCTION__, port->number); 956 + 957 + iuu_uart_off(port); 958 + if (serial->dev) { 959 + if (port->tty) { 960 + c_cflag = port->tty->termios->c_cflag; 961 + if (c_cflag & HUPCL) { 962 + /* drop DTR and RTS */ 963 + priv = usb_get_serial_port_data(port); 964 + spin_lock_irqsave(&priv->lock, flags); 965 + priv->line_control = 0; 966 + spin_unlock_irqrestore(&priv->lock, flags); 967 + set_control_lines(port->serial->dev, 0); 968 + } 969 + } 970 + /* free writebuf */ 971 + /* shutdown our urbs */ 972 + dbg("%s - shutting down urbs", __FUNCTION__); 973 + usb_kill_urb(port->write_urb); 974 + usb_kill_urb(port->read_urb); 975 + usb_kill_urb(port->interrupt_in_urb); 976 + msleep(1000); 977 + /* wait one second to free all buffers */ 978 + iuu_led(port, 0, 0, 0xF000, 0xFF); 979 + msleep(1000); 980 + usb_reset_device(port->serial->dev); 981 + } 982 + } 983 + 984 + static int iuu_open(struct usb_serial_port *port, struct file *filp) 985 + { 986 + struct usb_serial *serial = port->serial; 987 + u8 *buf; 988 + int result; 989 + u32 actual; 990 + unsigned long flags; 991 + struct iuu_private *priv = usb_get_serial_port_data(port); 992 + 993 + dbg("%s - port %d", __FUNCTION__, port->number); 994 + usb_clear_halt(serial->dev, port->write_urb->pipe); 995 + usb_clear_halt(serial->dev, port->read_urb->pipe); 996 + 997 + buf = kmalloc(10, GFP_KERNEL); 998 + if (buf == NULL) 999 + return -ENOMEM; 1000 + 1001 + /* fixup the endpoint buffer size */ 1002 + kfree(port->bulk_out_buffer); 1003 + port->bulk_out_buffer = kmalloc(512, GFP_KERNEL); 1004 + port->bulk_out_size = 512; 1005 + kfree(port->bulk_in_buffer); 1006 + port->bulk_in_buffer = kmalloc(512, GFP_KERNEL); 1007 + port->bulk_in_size = 512; 1008 + 1009 + if (!port->bulk_out_buffer || !port->bulk_in_buffer) { 1010 + kfree(port->bulk_out_buffer); 1011 + kfree(port->bulk_in_buffer); 1012 + kfree(buf); 1013 + return -ENOMEM; 1014 + } 1015 + 1016 + usb_fill_bulk_urb(port->write_urb, port->serial->dev, 1017 + usb_sndbulkpipe(port->serial->dev, 1018 + port->bulk_out_endpointAddress), 1019 + port->bulk_out_buffer, 512, 1020 + NULL, NULL); 1021 + 1022 + 1023 + usb_fill_bulk_urb(port->read_urb, port->serial->dev, 1024 + usb_rcvbulkpipe(port->serial->dev, 1025 + port->bulk_in_endpointAddress), 1026 + port->bulk_in_buffer, 512, 1027 + NULL, NULL); 1028 + 1029 + /* set the termios structure */ 1030 + spin_lock_irqsave(&priv->lock, flags); 1031 + if (!priv->termios_initialized) { 1032 + *(port->tty->termios) = tty_std_termios; 1033 + port->tty->termios->c_cflag = CLOCAL | CREAD | CS8 | B9600 1034 + | TIOCM_CTS | CSTOPB | PARENB; 1035 + port->tty->termios->c_lflag = 0; 1036 + port->tty->termios->c_oflag = 0; 1037 + port->tty->termios->c_iflag = 0; 1038 + priv->termios_initialized = 1; 1039 + port->tty->low_latency = 1; 1040 + priv->poll = 0; 1041 + } 1042 + spin_unlock_irqrestore(&priv->lock, flags); 1043 + 1044 + /* initialize writebuf */ 1045 + #define FISH(a, b, c, d) do { \ 1046 + result = usb_control_msg(port->serial->dev, \ 1047 + usb_rcvctrlpipe(port->serial->dev, 0), \ 1048 + b, a, c, d, buf, 1, 1000); \ 1049 + dbg("0x%x:0x%x:0x%x:0x%x %d - %x", a, b, c, d, result, \ 1050 + buf[0]); } while (0); 1051 + 1052 + #define SOUP(a, b, c, d) do { \ 1053 + result = usb_control_msg(port->serial->dev, \ 1054 + usb_sndctrlpipe(port->serial->dev, 0), \ 1055 + b, a, c, d, NULL, 0, 1000); \ 1056 + dbg("0x%x:0x%x:0x%x:0x%x %d", a, b, c, d, result); } while (0) 1057 + 1058 + /* This is not UART related but IUU USB driver related or something */ 1059 + /* like that. Basically no IUU will accept any commands from the USB */ 1060 + /* host unless it has received the following message */ 1061 + /* sprintf(buf ,"%c%c%c%c",0x03,0x02,0x02,0x0); */ 1062 + 1063 + SOUP(0x03, 0x02, 0x02, 0x0); 1064 + kfree(buf); 1065 + iuu_led(port, 0xF000, 0xF000, 0, 0xFF); 1066 + iuu_uart_on(port); 1067 + if (boost < 100) 1068 + boost = 100; 1069 + switch (clockmode) { 1070 + case 2: /* 3.680 Mhz */ 1071 + iuu_clk(port, IUU_CLK_3680000 * boost / 100); 1072 + result = 1073 + iuu_uart_baud(port, 9600 * boost / 100, &actual, 1074 + IUU_PARITY_EVEN); 1075 + break; 1076 + case 3: /* 6.00 Mhz */ 1077 + iuu_clk(port, IUU_CLK_6000000 * boost / 100); 1078 + result = 1079 + iuu_uart_baud(port, 16457 * boost / 100, &actual, 1080 + IUU_PARITY_EVEN); 1081 + break; 1082 + default: /* 3.579 Mhz */ 1083 + iuu_clk(port, IUU_CLK_3579000 * boost / 100); 1084 + result = 1085 + iuu_uart_baud(port, 9600 * boost / 100, &actual, 1086 + IUU_PARITY_EVEN); 1087 + } 1088 + 1089 + /* set the cardin cardout signals */ 1090 + switch (cdmode) { 1091 + case 0: 1092 + iuu_cardin = 0; 1093 + iuu_cardout = 0; 1094 + break; 1095 + case 1: 1096 + iuu_cardin = TIOCM_CD; 1097 + iuu_cardout = 0; 1098 + break; 1099 + case 2: 1100 + iuu_cardin = 0; 1101 + iuu_cardout = TIOCM_CD; 1102 + break; 1103 + case 3: 1104 + iuu_cardin = TIOCM_DSR; 1105 + iuu_cardout = 0; 1106 + break; 1107 + case 4: 1108 + iuu_cardin = 0; 1109 + iuu_cardout = TIOCM_DSR; 1110 + break; 1111 + case 5: 1112 + iuu_cardin = TIOCM_CTS; 1113 + iuu_cardout = 0; 1114 + break; 1115 + case 6: 1116 + iuu_cardin = 0; 1117 + iuu_cardout = TIOCM_CTS; 1118 + break; 1119 + case 7: 1120 + iuu_cardin = TIOCM_RNG; 1121 + iuu_cardout = 0; 1122 + break; 1123 + case 8: 1124 + iuu_cardin = 0; 1125 + iuu_cardout = TIOCM_RNG; 1126 + } 1127 + 1128 + iuu_uart_flush(port); 1129 + 1130 + dbg("%s - initialization done", __FUNCTION__); 1131 + 1132 + memset(port->write_urb->transfer_buffer, IUU_UART_RX, 1); 1133 + usb_fill_bulk_urb(port->write_urb, port->serial->dev, 1134 + usb_sndbulkpipe(port->serial->dev, 1135 + port->bulk_out_endpointAddress), 1136 + port->write_urb->transfer_buffer, 1, 1137 + read_rxcmd_callback, port); 1138 + result = usb_submit_urb(port->write_urb, GFP_KERNEL); 1139 + 1140 + if (result) { 1141 + dev_err(&port->dev, "%s - failed submitting read urb," 1142 + " error %d\n", __FUNCTION__, result); 1143 + iuu_close(port, NULL); 1144 + return -EPROTO; 1145 + } else { 1146 + dbg("%s - rxcmd OK", __FUNCTION__); 1147 + } 1148 + return result; 1149 + } 1150 + 1151 + static struct usb_serial_driver iuu_device = { 1152 + .driver = { 1153 + .owner = THIS_MODULE, 1154 + .name = "iuu_phoenix", 1155 + }, 1156 + .id_table = id_table, 1157 + .num_interrupt_in = NUM_DONT_CARE, 1158 + .num_bulk_in = 1, 1159 + .num_bulk_out = 1, 1160 + .num_ports = 1, 1161 + .open = iuu_open, 1162 + .close = iuu_close, 1163 + .write = iuu_uart_write, 1164 + .read_bulk_callback = iuu_uart_read_callback, 1165 + .tiocmget = iuu_tiocmget, 1166 + .tiocmset = iuu_tiocmset, 1167 + .attach = iuu_startup, 1168 + .shutdown = iuu_shutdown, 1169 + }; 1170 + 1171 + static int __init iuu_init(void) 1172 + { 1173 + int retval; 1174 + retval = usb_serial_register(&iuu_device); 1175 + if (retval) 1176 + goto failed_usb_serial_register; 1177 + retval = usb_register(&iuu_driver); 1178 + if (retval) 1179 + goto failed_usb_register; 1180 + info(DRIVER_DESC " " DRIVER_VERSION); 1181 + return 0; 1182 + failed_usb_register: 1183 + usb_serial_deregister(&iuu_device); 1184 + failed_usb_serial_register: 1185 + return retval; 1186 + } 1187 + 1188 + static void __exit iuu_exit(void) 1189 + { 1190 + usb_deregister(&iuu_driver); 1191 + usb_serial_deregister(&iuu_device); 1192 + } 1193 + 1194 + module_init(iuu_init); 1195 + module_exit(iuu_exit); 1196 + 1197 + MODULE_AUTHOR("Alain Degreffe eczema@ecze.com"); 1198 + 1199 + MODULE_DESCRIPTION(DRIVER_DESC); 1200 + MODULE_LICENSE("GPL"); 1201 + 1202 + MODULE_VERSION(DRIVER_VERSION); 1203 + module_param(debug, bool, S_IRUGO | S_IWUSR); 1204 + MODULE_PARM_DESC(debug, "Debug enabled or not"); 1205 + 1206 + module_param(xmas, bool, S_IRUGO | S_IWUSR); 1207 + MODULE_PARM_DESC(xmas, "xmas color enabled or not"); 1208 + 1209 + module_param(boost, int, S_IRUGO | S_IWUSR); 1210 + MODULE_PARM_DESC(boost, "overclock boost percent 100 to 500"); 1211 + 1212 + module_param(clockmode, int, S_IRUGO | S_IWUSR); 1213 + MODULE_PARM_DESC(clockmode, "1=3Mhz579,2=3Mhz680,3=6Mhz"); 1214 + 1215 + module_param(cdmode, int, S_IRUGO | S_IWUSR); 1216 + MODULE_PARM_DESC(cdmode, "Card detect mode 0=none, 1=CD, 2=!CD, 3=DSR, " 1217 + "4=!DSR, 5=CTS, 6=!CTS, 7=RING, 8=!RING");
+122
drivers/usb/serial/iuu_phoenix.h
··· 1 + /* 2 + * Infinity Unlimited USB Phoenix driver 3 + * 4 + * Copyright (C) 2007 Alain Degreffe (eczema@ecze.com) 5 + * 6 + * 7 + * Original code taken from iuutool ( Copyright (C) 2006 Juan Carlos Borrás ) 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 + * And tested with help of WB Electronics 15 + * 16 + */ 17 + 18 + #define IUU_USB_VENDOR_ID 0x104f 19 + #define IUU_USB_PRODUCT_ID 0x0004 20 + #define IUU_USB_OP_TIMEOUT 0x0200 21 + 22 + /* Programmer commands */ 23 + 24 + #define IUU_NO_OPERATION 0x00 25 + #define IUU_GET_FIRMWARE_VERSION 0x01 26 + #define IUU_GET_PRODUCT_NAME 0x02 27 + #define IUU_GET_STATE_REGISTER 0x03 28 + #define IUU_SET_LED 0x04 29 + #define IUU_WAIT_MUS 0x05 30 + #define IUU_WAIT_MS 0x06 31 + #define IUU_GET_LOADER_VERSION 0x50 32 + #define IUU_RST_SET 0x52 33 + #define IUU_RST_CLEAR 0x53 34 + #define IUU_SET_VCC 0x59 35 + #define IUU_UART_ENABLE 0x49 36 + #define IUU_UART_DISABLE 0x4A 37 + #define IUU_UART_WRITE_I2C 0x4C 38 + #define IUU_UART_ESC 0x5E 39 + #define IUU_UART_TRAP 0x54 40 + #define IUU_UART_TRAP_BREAK 0x5B 41 + #define IUU_UART_RX 0x56 42 + #define IUU_AVR_ON 0x21 43 + #define IUU_AVR_OFF 0x22 44 + #define IUU_AVR_1CLK 0x23 45 + #define IUU_AVR_RESET 0x24 46 + #define IUU_AVR_RESET_PC 0x25 47 + #define IUU_AVR_INC_PC 0x26 48 + #define IUU_AVR_INCN_PC 0x27 49 + #define IUU_AVR_PREAD 0x29 50 + #define IUU_AVR_PREADN 0x2A 51 + #define IUU_AVR_PWRITE 0x28 52 + #define IUU_AVR_DREAD 0x2C 53 + #define IUU_AVR_DREADN 0x2D 54 + #define IUU_AVR_DWRITE 0x2B 55 + #define IUU_AVR_PWRITEN 0x2E 56 + #define IUU_EEPROM_ON 0x37 57 + #define IUU_EEPROM_OFF 0x38 58 + #define IUU_EEPROM_WRITE 0x39 59 + #define IUU_EEPROM_WRITEX 0x3A 60 + #define IUU_EEPROM_WRITE8 0x3B 61 + #define IUU_EEPROM_WRITE16 0x3C 62 + #define IUU_EEPROM_WRITEX32 0x3D 63 + #define IUU_EEPROM_WRITEX64 0x3E 64 + #define IUU_EEPROM_READ 0x3F 65 + #define IUU_EEPROM_READX 0x40 66 + #define IUU_EEPROM_BREAD 0x41 67 + #define IUU_EEPROM_BREADX 0x42 68 + #define IUU_PIC_CMD 0x0A 69 + #define IUU_PIC_CMD_LOAD 0x0B 70 + #define IUU_PIC_CMD_READ 0x0C 71 + #define IUU_PIC_ON 0x0D 72 + #define IUU_PIC_OFF 0x0E 73 + #define IUU_PIC_RESET 0x16 74 + #define IUU_PIC_INC_PC 0x0F 75 + #define IUU_PIC_INCN_PC 0x10 76 + #define IUU_PIC_PWRITE 0x11 77 + #define IUU_PIC_PREAD 0x12 78 + #define IUU_PIC_PREADN 0x13 79 + #define IUU_PIC_DWRITE 0x14 80 + #define IUU_PIC_DREAD 0x15 81 + #define IUU_UART_NOP 0x00 82 + #define IUU_UART_CHANGE 0x02 83 + #define IUU_UART_TX 0x04 84 + #define IUU_DELAY_MS 0x06 85 + 86 + #define IUU_OPERATION_OK 0x00 87 + #define IUU_DEVICE_NOT_FOUND 0x01 88 + #define IUU_INVALID_HANDLE 0x02 89 + #define IUU_INVALID_PARAMETER 0x03 90 + #define IUU_INVALID_voidERFACE 0x04 91 + #define IUU_INVALID_REQUEST_LENGTH 0x05 92 + #define IUU_UART_NOT_ENABLED 0x06 93 + #define IUU_WRITE_ERROR 0x07 94 + #define IUU_READ_ERROR 0x08 95 + #define IUU_TX_ERROR 0x09 96 + #define IUU_RX_ERROR 0x0A 97 + 98 + #define IUU_PARITY_NONE 0x00 99 + #define IUU_PARITY_EVEN 0x01 100 + #define IUU_PARITY_ODD 0x02 101 + #define IUU_PARITY_MARK 0x03 102 + #define IUU_PARITY_SPACE 0x04 103 + #define IUU_SC_INSERTED 0x01 104 + #define IUU_VERIFY_ERROR 0x02 105 + #define IUU_SIM_INSERTED 0x04 106 + #define IUU_TWO_STOP_BITS 0x00 107 + #define IUU_ONE_STOP_BIT 0x20 108 + #define IUU_BAUD_2400 0x0398 109 + #define IUU_BAUD_9600 0x0298 110 + #define IUU_BAUD_19200 0x0164 111 + #define IUU_BAUD_28800 0x0198 112 + #define IUU_BAUD_38400 0x01B2 113 + #define IUU_BAUD_57600 0x0030 114 + #define IUU_BAUD_115200 0x0098 115 + #define IUU_CLK_3579000 3579000 116 + #define IUU_CLK_3680000 3680000 117 + #define IUU_CLK_6000000 6000000 118 + #define IUU_FULLCARD_IN 0x01 119 + #define IUU_DEV_ERROR 0x02 120 + #define IUU_MINICARD_IN 0x04 121 + #define IUU_VCC_5V 0x00 122 + #define IUU_VCC_3V 0x01
+1 -1
drivers/usb/serial/keyspan.c
··· 838 838 839 839 port = (struct usb_serial_port *) urb->context; 840 840 tty = port->tty; 841 - if (urb->actual_length) { 841 + if (tty && urb->actual_length) { 842 842 /* 0x80 bit is error flag */ 843 843 if ((data[0] & 0x80) == 0) { 844 844 /* no error on any byte */
+19 -19
drivers/usb/serial/keyspan_pda.c
··· 303 303 } 304 304 305 305 306 - static int keyspan_pda_setbaud (struct usb_serial *serial, int baud) 306 + static speed_t keyspan_pda_setbaud (struct usb_serial *serial, speed_t baud) 307 307 { 308 308 int rc; 309 309 int bindex; ··· 319 319 case 38400: bindex = 7; break; 320 320 case 57600: bindex = 8; break; 321 321 case 115200: bindex = 9; break; 322 - default: return -EINVAL; 322 + default: 323 + bindex = 5; /* Default to 9600 */ 324 + baud = 9600; 323 325 } 324 326 325 327 /* rather than figure out how to sleep while waiting for this ··· 336 334 NULL, /* &data */ 337 335 0, /* size */ 338 336 2000); /* timeout */ 339 - return(rc); 337 + if (rc < 0) 338 + return 0; 339 + return baud; 340 340 } 341 341 342 342 ··· 370 366 struct ktermios *old_termios) 371 367 { 372 368 struct usb_serial *serial = port->serial; 373 - unsigned int cflag = port->tty->termios->c_cflag; 369 + speed_t speed; 374 370 375 371 /* cflag specifies lots of stuff: number of stop bits, parity, number 376 372 of data bits, baud. What can the device actually handle?: ··· 392 388 393 389 For now, just do baud. */ 394 390 395 - switch (cflag & CBAUD) { 396 - /* we could support more values here, just need to calculate 397 - the necessary divisors in the firmware. <asm/termbits.h> 398 - has the Bnnn constants. */ 399 - case B110: keyspan_pda_setbaud(serial, 110); break; 400 - case B300: keyspan_pda_setbaud(serial, 300); break; 401 - case B1200: keyspan_pda_setbaud(serial, 1200); break; 402 - case B2400: keyspan_pda_setbaud(serial, 2400); break; 403 - case B4800: keyspan_pda_setbaud(serial, 4800); break; 404 - case B9600: keyspan_pda_setbaud(serial, 9600); break; 405 - case B19200: keyspan_pda_setbaud(serial, 19200); break; 406 - case B38400: keyspan_pda_setbaud(serial, 38400); break; 407 - case B57600: keyspan_pda_setbaud(serial, 57600); break; 408 - case B115200: keyspan_pda_setbaud(serial, 115200); break; 409 - default: dbg("can't handle requested baud rate"); break; 391 + speed = tty_get_baud_rate(port->tty); 392 + speed = keyspan_pda_setbaud(serial, speed); 393 + 394 + if (speed == 0) { 395 + dbg("can't handle requested baud rate"); 396 + /* It hasn't changed so.. */ 397 + speed = tty_termios_baud_rate(old_termios); 410 398 } 399 + /* Only speed can change so copy the old h/w parameters 400 + then encode the new speed */ 401 + tty_termios_copy_hw(port->tty->termios, old_termios); 402 + tty_encode_baud_rate(port->tty, speed, speed); 411 403 } 412 404 413 405
+15 -11
drivers/usb/serial/kl5kusb105.c
··· 461 461 462 462 dbg("%s port %d", __FUNCTION__, port->number); 463 463 464 - /* send READ_OFF */ 465 - rc = usb_control_msg (port->serial->dev, 466 - usb_sndctrlpipe(port->serial->dev, 0), 467 - KL5KUSB105A_SIO_CONFIGURE, 468 - USB_TYPE_VENDOR | USB_DIR_OUT, 469 - KL5KUSB105A_SIO_CONFIGURE_READ_OFF, 470 - 0, /* index */ 471 - NULL, 0, 472 - KLSI_TIMEOUT); 473 - if (rc < 0) 474 - err("Disabling read failed (error = %d)", rc); 464 + mutex_lock(&port->serial->disc_mutex); 465 + if (!port->serial->disconnected) { 466 + /* send READ_OFF */ 467 + rc = usb_control_msg (port->serial->dev, 468 + usb_sndctrlpipe(port->serial->dev, 0), 469 + KL5KUSB105A_SIO_CONFIGURE, 470 + USB_TYPE_VENDOR | USB_DIR_OUT, 471 + KL5KUSB105A_SIO_CONFIGURE_READ_OFF, 472 + 0, /* index */ 473 + NULL, 0, 474 + KLSI_TIMEOUT); 475 + if (rc < 0) 476 + err("Disabling read failed (error = %d)", rc); 477 + } 478 + mutex_unlock(&port->serial->disc_mutex); 475 479 476 480 /* shutdown our bulk reads and writes */ 477 481 usb_kill_urb(port->write_urb);
+1
drivers/usb/serial/kobil_sct.c
··· 114 114 .usb_driver = &kobil_driver, 115 115 .id_table = id_table, 116 116 .num_interrupt_in = NUM_DONT_CARE, 117 + .num_interrupt_out = NUM_DONT_CARE, 117 118 .num_bulk_in = 0, 118 119 .num_bulk_out = 0, 119 120 .num_ports = 1,
+26 -17
drivers/usb/serial/mct_u232.c
··· 182 182 /* 183 183 * Later day 2.6.0-test kernels have new baud rates like B230400 which 184 184 * we do not know how to support. We ignore them for the moment. 185 - * XXX Rate-limit the error message, it's user triggerable. 186 185 */ 187 - static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value) 186 + static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value, speed_t *result) 188 187 { 188 + *result = value; 189 + 189 190 if (le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_SITECOM_PID 190 191 || le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_BELKIN_F5U109_PID) { 191 192 switch (value) { ··· 201 200 case 57600: return 0x0b; 202 201 case 115200: return 0x0c; 203 202 default: 204 - err("MCT USB-RS232: unsupported baudrate request 0x%x," 205 - " using default of B9600", value); 203 + *result = 9600; 206 204 return 0x08; 207 205 } 208 206 } else { 207 + /* FIXME: Can we use any divider - should we do 208 + divider = 115200/value; 209 + real baud = 115200/divider */ 209 210 switch (value) { 210 211 case 300: break; 211 212 case 600: break; ··· 220 217 case 57600: break; 221 218 case 115200: break; 222 219 default: 223 - err("MCT USB-RS232: unsupported baudrate request 0x%x," 224 - " using default of B9600", value); 225 220 value = 9600; 221 + *result = 9600; 226 222 } 227 223 return 115200/value; 228 224 } ··· 234 232 int rc; 235 233 unsigned char zero_byte = 0; 236 234 unsigned char cts_enable_byte = 0; 235 + speed_t speed; 237 236 238 - divisor = cpu_to_le32(mct_u232_calculate_baud_rate(serial, value)); 237 + divisor = cpu_to_le32(mct_u232_calculate_baud_rate(serial, value, &speed)); 239 238 240 239 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 241 240 MCT_U232_SET_BAUD_RATE_REQUEST, 242 241 MCT_U232_SET_REQUEST_TYPE, 243 242 0, 0, &divisor, MCT_U232_SET_BAUD_RATE_SIZE, 244 243 WDR_TIMEOUT); 245 - if (rc < 0) 244 + if (rc < 0) /*FIXME: What value speed results */ 246 245 err("Set BAUD RATE %d failed (error = %d)", value, rc); 246 + else 247 + tty_encode_baud_rate(port->tty, speed, speed); 247 248 dbg("set_baud_rate: value: 0x%x, divisor: 0x%x", value, divisor); 248 249 249 250 /* Mimic the MCT-supplied Windows driver (version 1.21P.0104), which ··· 487 482 static void mct_u232_close (struct usb_serial_port *port, struct file *filp) 488 483 { 489 484 unsigned int c_cflag; 490 - unsigned long flags; 491 485 unsigned int control_state; 492 486 struct mct_u232_private *priv = usb_get_serial_port_data(port); 493 487 dbg("%s port %d", __FUNCTION__, port->number); 494 488 495 489 if (port->tty) { 496 490 c_cflag = port->tty->termios->c_cflag; 497 - if (c_cflag & HUPCL) { 498 - /* drop DTR and RTS */ 499 - spin_lock_irqsave(&priv->lock, flags); 500 - priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); 501 - control_state = priv->control_state; 502 - spin_unlock_irqrestore(&priv->lock, flags); 503 - mct_u232_set_modem_ctrl(port->serial, control_state); 491 + mutex_lock(&port->serial->disc_mutex); 492 + if (c_cflag & HUPCL && !port->serial->disconnected) { 493 + /* drop DTR and RTS */ 494 + spin_lock_irq(&priv->lock); 495 + priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); 496 + control_state = priv->control_state; 497 + spin_unlock_irq(&priv->lock); 498 + mct_u232_set_modem_ctrl(port->serial, control_state); 504 499 } 500 + mutex_unlock(&port->serial->disc_mutex); 505 501 } 506 502 507 503 ··· 614 608 { 615 609 struct usb_serial *serial = port->serial; 616 610 struct mct_u232_private *priv = usb_get_serial_port_data(port); 617 - unsigned int cflag = port->tty->termios->c_cflag; 611 + struct ktermios *termios = port->tty->termios; 612 + unsigned int cflag = termios->c_cflag; 618 613 unsigned int old_cflag = old_termios->c_cflag; 619 614 unsigned long flags; 620 615 unsigned int control_state; ··· 676 669 last_lcr |= MCT_U232_DATA_BITS_8; 677 670 break; 678 671 } 672 + 673 + termios->c_cflag &= ~CMSPAR; 679 674 680 675 /* set the number of stop bits */ 681 676 last_lcr |= (cflag & CSTOPB) ?
+1 -1
drivers/usb/serial/mct_u232.h
··· 79 79 * and "Intel solution". They are the regular MCT and "Sitecom" for us. 80 80 * This is pointless to document in the header, see the code for the bits. 81 81 */ 82 - static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value); 82 + static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value, speed_t *result); 83 83 84 84 /* 85 85 * Line Control Register (LCR)
+26 -35
drivers/usb/serial/mos7720.c
··· 564 564 } 565 565 566 566 /* While closing port, shutdown all bulk read, write * 567 - * and interrupt read if they exists */ 568 - if (serial->dev) { 569 - dbg("Shutdown bulk write"); 570 - usb_kill_urb(port->write_urb); 571 - dbg("Shutdown bulk read"); 572 - usb_kill_urb(port->read_urb); 567 + * and interrupt read if they exists, otherwise nop */ 568 + dbg("Shutdown bulk write"); 569 + usb_kill_urb(port->write_urb); 570 + dbg("Shutdown bulk read"); 571 + usb_kill_urb(port->read_urb); 572 + 573 + mutex_lock(&serial->disc_mutex); 574 + /* these commands must not be issued if the device has 575 + * been disconnected */ 576 + if (!serial->disconnected) { 577 + data = 0x00; 578 + send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor, 579 + 0x04, &data); 580 + 581 + data = 0x00; 582 + send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor, 583 + 0x01, &data); 573 584 } 574 - 575 - data = 0x00; 576 - send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor, 577 - 0x04, &data); 578 - 579 - data = 0x00; 580 - send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor, 581 - 0x01, &data); 582 - 585 + mutex_unlock(&serial->disc_mutex); 583 586 mos7720_port->open = 0; 584 587 585 588 dbg("Leaving %s", __FUNCTION__); ··· 1043 1040 1044 1041 tty = mos7720_port->port->tty; 1045 1042 1046 - if ((!tty) || (!tty->termios)) { 1047 - dbg("%s - no tty structures", __FUNCTION__); 1048 - return; 1049 - } 1050 - 1051 1043 dbg("%s: Entering ..........", __FUNCTION__); 1052 1044 1053 1045 lData = UART_LCR_WLEN8; ··· 1173 1175 1174 1176 dbg("%s - baud rate = %d", __FUNCTION__, baud); 1175 1177 status = send_cmd_write_baud_rate(mos7720_port, baud); 1176 - 1178 + /* FIXME: needs to write actual resulting baud back not just 1179 + blindly do so */ 1180 + if (cflag & CBAUD) 1181 + tty_encode_baud_rate(tty, baud, baud); 1177 1182 /* Enable Interrupts */ 1178 1183 data = 0x0c; 1179 1184 send_mos_cmd(serial, MOS_WRITE, port_number, UART_IER, &data); ··· 1215 1214 1216 1215 tty = port->tty; 1217 1216 1218 - if (!port->tty || !port->tty->termios) { 1219 - dbg("%s - no tty or termios", __FUNCTION__); 1220 - return; 1221 - } 1222 1217 1223 1218 if (!mos7720_port->open) { 1224 1219 dbg("%s - port not opened", __FUNCTION__); ··· 1225 1228 1226 1229 cflag = tty->termios->c_cflag; 1227 1230 1228 - if (!cflag) { 1229 - printk("%s %s\n",__FUNCTION__,"cflag is NULL"); 1230 - return; 1231 - } 1232 - 1233 - dbg("%s - clfag %08x iflag %08x", __FUNCTION__, 1231 + dbg("%s - cflag %08x iflag %08x", __FUNCTION__, 1234 1232 tty->termios->c_cflag, 1235 1233 RELEVANT_IFLAG(tty->termios->c_iflag)); 1236 1234 1237 - if (old_termios) 1238 - dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__, 1239 - old_termios->c_cflag, 1240 - RELEVANT_IFLAG(old_termios->c_iflag)); 1235 + dbg("%s - old cflag %08x old iflag %08x", __FUNCTION__, 1236 + old_termios->c_cflag, 1237 + RELEVANT_IFLAG(old_termios->c_iflag)); 1241 1238 1242 1239 dbg("%s - port %d", __FUNCTION__, port->number); 1243 1240
+4 -4
drivers/usb/serial/mos7840.c
··· 1133 1133 * This function will block the close until one of the following: 1134 1134 * 1. TX count are 0 1135 1135 * 2. The mos7840 has stopped 1136 - * 3. A timout of 3 seconds without activity has expired 1136 + * 3. A timeout of 3 seconds without activity has expired 1137 1137 * 1138 1138 ************************************************************************/ 1139 1139 static void mos7840_block_until_tx_empty(struct moschip_port *mos7840_port) ··· 1161 1161 dbg("%s - TIMEOUT", __FUNCTION__); 1162 1162 return; 1163 1163 } else { 1164 - /* Reset timout value back to seconds */ 1164 + /* Reset timeout value back to seconds */ 1165 1165 wait = 30; 1166 1166 } 1167 1167 } ··· 1275 1275 * 1276 1276 * This function will block the close until one of the following: 1277 1277 * 1. Response to our Chase comes from mos7840 1278 - * 2. A timout of 10 seconds without activity has expired 1278 + * 2. A timeout of 10 seconds without activity has expired 1279 1279 * (1K of mos7840 data @ 2400 baud ==> 4 sec to empty) 1280 1280 * 1281 1281 ************************************************************************/ ··· 1304 1304 dbg("%s - TIMEOUT", __FUNCTION__); 1305 1305 return; 1306 1306 } else { 1307 - /* Reset timout value back to seconds */ 1307 + /* Reset timeout value back to seconds */ 1308 1308 wait = 10; 1309 1309 } 1310 1310 }
+5 -1
drivers/usb/serial/option.c
··· 180 180 { USB_DEVICE(DELL_VENDOR_ID, 0x8117) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO ExpressCard == Novatel Merlin XV620 CDMA/EV-DO */ 181 181 { USB_DEVICE(DELL_VENDOR_ID, 0x8118) }, /* Dell Wireless 5510 Mobile Broadband HSDPA ExpressCard == Novatel Merlin XU870 HSDPA/3G */ 182 182 { USB_DEVICE(DELL_VENDOR_ID, 0x8128) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite E720 CDMA/EV-DO */ 183 + { USB_DEVICE(DELL_VENDOR_ID, 0x8136) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */ 183 184 { USB_DEVICE(DELL_VENDOR_ID, 0x8137) }, /* Dell Wireless HSDPA 5520 */ 184 185 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, 185 186 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, ··· 641 640 portdata->dtr_state = 0; 642 641 643 642 if (serial->dev) { 644 - option_send_setup(port); 643 + mutex_lock(&serial->disc_mutex); 644 + if (!serial->disconnected) 645 + option_send_setup(port); 646 + mutex_unlock(&serial->disc_mutex); 645 647 646 648 /* Stop reading/writing urbs */ 647 649 for (i = 0; i < N_IN_URB; i++)
+47 -84
drivers/usb/serial/oti6858.c
··· 79 79 #define PL2303_BUF_SIZE 1024 80 80 #define PL2303_TMP_BUF_SIZE 1024 81 81 82 - struct pl2303_buf { 82 + struct oti6858_buf { 83 83 unsigned int buf_size; 84 84 char *buf_buf; 85 85 char *buf_get; ··· 161 161 static void oti6858_shutdown(struct usb_serial *serial); 162 162 163 163 /* functions operating on buffers */ 164 - static struct pl2303_buf *pl2303_buf_alloc(unsigned int size); 165 - static void pl2303_buf_free(struct pl2303_buf *pb); 166 - static void pl2303_buf_clear(struct pl2303_buf *pb); 167 - static unsigned int pl2303_buf_data_avail(struct pl2303_buf *pb); 168 - static unsigned int pl2303_buf_space_avail(struct pl2303_buf *pb); 169 - static unsigned int pl2303_buf_put(struct pl2303_buf *pb, const char *buf, 164 + static struct oti6858_buf *oti6858_buf_alloc(unsigned int size); 165 + static void oti6858_buf_free(struct oti6858_buf *pb); 166 + static void oti6858_buf_clear(struct oti6858_buf *pb); 167 + static unsigned int oti6858_buf_data_avail(struct oti6858_buf *pb); 168 + static unsigned int oti6858_buf_space_avail(struct oti6858_buf *pb); 169 + static unsigned int oti6858_buf_put(struct oti6858_buf *pb, const char *buf, 170 170 unsigned int count); 171 - static unsigned int pl2303_buf_get(struct pl2303_buf *pb, char *buf, 171 + static unsigned int oti6858_buf_get(struct oti6858_buf *pb, char *buf, 172 172 unsigned int count); 173 173 174 174 ··· 203 203 struct oti6858_private { 204 204 spinlock_t lock; 205 205 206 - struct pl2303_buf *buf; 206 + struct oti6858_buf *buf; 207 207 struct oti6858_control_pkt status; 208 208 209 209 struct { ··· 316 316 } 317 317 priv->flags.write_urb_in_use = 1; 318 318 319 - count = pl2303_buf_data_avail(priv->buf); 319 + count = oti6858_buf_data_avail(priv->buf); 320 320 spin_unlock_irqrestore(&priv->lock, flags); 321 321 if (count > port->bulk_out_size) 322 322 count = port->bulk_out_size; ··· 345 345 } 346 346 347 347 spin_lock_irqsave(&priv->lock, flags); 348 - pl2303_buf_get(priv->buf, port->write_urb->transfer_buffer, count); 348 + oti6858_buf_get(priv->buf, port->write_urb->transfer_buffer, count); 349 349 spin_unlock_irqrestore(&priv->lock, flags); 350 350 351 351 port->write_urb->transfer_buffer_length = count; ··· 370 370 priv = kzalloc(sizeof(struct oti6858_private), GFP_KERNEL); 371 371 if (!priv) 372 372 break; 373 - priv->buf = pl2303_buf_alloc(PL2303_BUF_SIZE); 373 + priv->buf = oti6858_buf_alloc(PL2303_BUF_SIZE); 374 374 if (priv->buf == NULL) { 375 375 kfree(priv); 376 376 break; ··· 391 391 392 392 for (--i; i >= 0; --i) { 393 393 priv = usb_get_serial_port_data(serial->port[i]); 394 - pl2303_buf_free(priv->buf); 394 + oti6858_buf_free(priv->buf); 395 395 kfree(priv); 396 396 usb_set_serial_port_data(serial->port[i], NULL); 397 397 } ··· 410 410 return count; 411 411 412 412 spin_lock_irqsave(&priv->lock, flags); 413 - count = pl2303_buf_put(priv->buf, buf, count); 413 + count = oti6858_buf_put(priv->buf, buf, count); 414 414 spin_unlock_irqrestore(&priv->lock, flags); 415 415 416 416 return count; ··· 425 425 dbg("%s(port = %d)", __FUNCTION__, port->number); 426 426 427 427 spin_lock_irqsave(&priv->lock, flags); 428 - room = pl2303_buf_space_avail(priv->buf); 428 + room = oti6858_buf_space_avail(priv->buf); 429 429 spin_unlock_irqrestore(&priv->lock, flags); 430 430 431 431 return room; ··· 440 440 dbg("%s(port = %d)", __FUNCTION__, port->number); 441 441 442 442 spin_lock_irqsave(&priv->lock, flags); 443 - chars = pl2303_buf_data_avail(priv->buf); 443 + chars = oti6858_buf_data_avail(priv->buf); 444 444 spin_unlock_irqrestore(&priv->lock, flags); 445 445 446 446 return chars; ··· 458 458 459 459 dbg("%s(port = %d)", __FUNCTION__, port->number); 460 460 461 - if ((!port->tty) || (!port->tty->termios)) { 461 + if (!port->tty || !port->tty->termios) { 462 462 dbg("%s(): no tty structures", __FUNCTION__); 463 463 return; 464 464 } ··· 468 468 *(port->tty->termios) = tty_std_termios; 469 469 port->tty->termios->c_cflag = B38400 | CS8 | CREAD | HUPCL | CLOCAL; 470 470 priv->flags.termios_initialized = 1; 471 + port->tty->termios->c_ispeed = 38400; 472 + port->tty->termios->c_ospeed = 38400; 471 473 } 472 474 spin_unlock_irqrestore(&priv->lock, flags); 473 475 ··· 506 504 br = tty_get_baud_rate(port->tty); 507 505 if (br == 0) { 508 506 divisor = 0; 509 - } else if (br <= OTI6858_MAX_BAUD_RATE) { 507 + } else { 510 508 int real_br; 509 + br = min(br, OTI6858_MAX_BAUD_RATE); 511 510 512 511 divisor = (96000000 + 8 * br) / (16 * br); 513 512 real_br = 96000000 / (16 * divisor); 514 - if ((((real_br - br) * 100 + br - 1) / br) > 2) { 515 - dbg("%s(): baud rate %d is invalid", __FUNCTION__, br); 516 - return; 517 - } 518 513 divisor = cpu_to_le16(divisor); 519 - } else { 520 - dbg("%s(): baud rate %d is too high", __FUNCTION__, br); 521 - return; 514 + tty_encode_baud_rate(port->tty, real_br, real_br); 522 515 } 523 516 524 517 frame_fmt &= ~FMT_STOP_BITS_MASK; ··· 647 650 dbg("%s(): entering wait loop", __FUNCTION__); 648 651 for (;;) { 649 652 set_current_state(TASK_INTERRUPTIBLE); 650 - if (pl2303_buf_data_avail(priv->buf) == 0 653 + if (oti6858_buf_data_avail(priv->buf) == 0 651 654 || timeout == 0 || signal_pending(current) 652 - || !usb_get_intfdata(port->serial->interface)) /* disconnect */ 655 + || port->serial->disconnected) 653 656 break; 654 657 spin_unlock_irqrestore(&priv->lock, flags); 655 658 timeout = schedule_timeout(timeout); ··· 660 663 dbg("%s(): after wait loop", __FUNCTION__); 661 664 662 665 /* clear out any remaining data in the buffer */ 663 - pl2303_buf_clear(priv->buf); 666 + oti6858_buf_clear(priv->buf); 664 667 spin_unlock_irqrestore(&priv->lock, flags); 665 668 666 669 /* wait for characters to drain from the device */ ··· 828 831 return -EFAULT; 829 832 return oti6858_tiocmset(port, NULL, 0, x); 830 833 831 - case TIOCGSERIAL: 832 - if (copy_to_user(user_arg, port->tty->termios, 833 - sizeof(struct ktermios))) { 834 - return -EFAULT; 835 - } 836 - return 0; 837 - 838 - case TIOCSSERIAL: 839 - if (copy_from_user(port->tty->termios, user_arg, 840 - sizeof(struct ktermios))) { 841 - return -EFAULT; 842 - } 843 - oti6858_set_termios(port, NULL); 844 - return 0; 845 - 846 834 case TIOCMIWAIT: 847 835 dbg("%s(): TIOCMIWAIT", __FUNCTION__); 848 836 return wait_modem_info(port, arg); ··· 869 887 for (i = 0; i < serial->num_ports; ++i) { 870 888 priv = usb_get_serial_port_data(serial->port[i]); 871 889 if (priv) { 872 - pl2303_buf_free(priv->buf); 890 + oti6858_buf_free(priv->buf); 873 891 kfree(priv); 874 892 usb_set_serial_port_data(serial->port[i], NULL); 875 893 } ··· 969 987 970 988 spin_lock_irqsave(&priv->lock, flags); 971 989 if (priv->flags.write_urb_in_use == 0 972 - && pl2303_buf_data_avail(priv->buf) != 0) { 990 + && oti6858_buf_data_avail(priv->buf) != 0) { 973 991 schedule_delayed_work(&priv->delayed_write_work,0); 974 992 resubmit = 0; 975 993 } ··· 997 1015 struct tty_struct *tty; 998 1016 unsigned char *data = urb->transfer_buffer; 999 1017 unsigned long flags; 1000 - int i, result; 1001 1018 int status = urb->status; 1002 - char tty_flag; 1019 + int result; 1003 1020 1004 1021 dbg("%s(port = %d, status = %d)", 1005 1022 __FUNCTION__, port->number, status); ··· 1026 1045 return; 1027 1046 } 1028 1047 1029 - // get tty_flag from status 1030 - tty_flag = TTY_NORMAL; 1031 - 1032 - /* FIXME: probably, errors will be signalled using interrupt pipe! */ 1033 - /* 1034 - // break takes precedence over parity, 1035 - // which takes precedence over framing errors 1036 - if (status & UART_BREAK_ERROR ) 1037 - tty_flag = TTY_BREAK; 1038 - else if (status & UART_PARITY_ERROR) 1039 - tty_flag = TTY_PARITY; 1040 - else if (status & UART_FRAME_ERROR) 1041 - tty_flag = TTY_FRAME; 1042 - dbg("%s - tty_flag = %d", __FUNCTION__, tty_flag); 1043 - */ 1044 - 1045 1048 tty = port->tty; 1046 1049 if (tty != NULL && urb->actual_length > 0) { 1047 - tty_buffer_request_room(tty, urb->actual_length); 1048 - for (i = 0; i < urb->actual_length; ++i) 1049 - tty_insert_flip_char(tty, data[i], tty_flag); 1050 + tty_insert_flip_string(tty, data, urb->actual_length); 1050 1051 tty_flip_buffer_push(tty); 1051 1052 } 1052 1053 ··· 1096 1133 1097 1134 1098 1135 /* 1099 - * pl2303_buf_alloc 1136 + * oti6858_buf_alloc 1100 1137 * 1101 1138 * Allocate a circular buffer and all associated memory. 1102 1139 */ 1103 - static struct pl2303_buf *pl2303_buf_alloc(unsigned int size) 1140 + static struct oti6858_buf *oti6858_buf_alloc(unsigned int size) 1104 1141 { 1105 - struct pl2303_buf *pb; 1142 + struct oti6858_buf *pb; 1106 1143 1107 1144 if (size == 0) 1108 1145 return NULL; 1109 1146 1110 - pb = kmalloc(sizeof(struct pl2303_buf), GFP_KERNEL); 1147 + pb = kmalloc(sizeof(struct oti6858_buf), GFP_KERNEL); 1111 1148 if (pb == NULL) 1112 1149 return NULL; 1113 1150 ··· 1124 1161 } 1125 1162 1126 1163 /* 1127 - * pl2303_buf_free 1164 + * oti6858_buf_free 1128 1165 * 1129 1166 * Free the buffer and all associated memory. 1130 1167 */ 1131 - static void pl2303_buf_free(struct pl2303_buf *pb) 1168 + static void oti6858_buf_free(struct oti6858_buf *pb) 1132 1169 { 1133 1170 if (pb) { 1134 1171 kfree(pb->buf_buf); ··· 1137 1174 } 1138 1175 1139 1176 /* 1140 - * pl2303_buf_clear 1177 + * oti6858_buf_clear 1141 1178 * 1142 1179 * Clear out all data in the circular buffer. 1143 1180 */ 1144 - static void pl2303_buf_clear(struct pl2303_buf *pb) 1181 + static void oti6858_buf_clear(struct oti6858_buf *pb) 1145 1182 { 1146 1183 if (pb != NULL) { 1147 1184 /* equivalent to a get of all data available */ ··· 1150 1187 } 1151 1188 1152 1189 /* 1153 - * pl2303_buf_data_avail 1190 + * oti6858_buf_data_avail 1154 1191 * 1155 1192 * Return the number of bytes of data available in the circular 1156 1193 * buffer. 1157 1194 */ 1158 - static unsigned int pl2303_buf_data_avail(struct pl2303_buf *pb) 1195 + static unsigned int oti6858_buf_data_avail(struct oti6858_buf *pb) 1159 1196 { 1160 1197 if (pb == NULL) 1161 1198 return 0; ··· 1163 1200 } 1164 1201 1165 1202 /* 1166 - * pl2303_buf_space_avail 1203 + * oti6858_buf_space_avail 1167 1204 * 1168 1205 * Return the number of bytes of space available in the circular 1169 1206 * buffer. 1170 1207 */ 1171 - static unsigned int pl2303_buf_space_avail(struct pl2303_buf *pb) 1208 + static unsigned int oti6858_buf_space_avail(struct oti6858_buf *pb) 1172 1209 { 1173 1210 if (pb == NULL) 1174 1211 return 0; ··· 1176 1213 } 1177 1214 1178 1215 /* 1179 - * pl2303_buf_put 1216 + * oti6858_buf_put 1180 1217 * 1181 1218 * Copy data data from a user buffer and put it into the circular buffer. 1182 1219 * Restrict to the amount of space available. 1183 1220 * 1184 1221 * Return the number of bytes copied. 1185 1222 */ 1186 - static unsigned int pl2303_buf_put(struct pl2303_buf *pb, const char *buf, 1223 + static unsigned int oti6858_buf_put(struct oti6858_buf *pb, const char *buf, 1187 1224 unsigned int count) 1188 1225 { 1189 1226 unsigned int len; ··· 1191 1228 if (pb == NULL) 1192 1229 return 0; 1193 1230 1194 - len = pl2303_buf_space_avail(pb); 1231 + len = oti6858_buf_space_avail(pb); 1195 1232 if (count > len) 1196 1233 count = len; 1197 1234 ··· 1215 1252 } 1216 1253 1217 1254 /* 1218 - * pl2303_buf_get 1255 + * oti6858_buf_get 1219 1256 * 1220 1257 * Get data from the circular buffer and copy to the given buffer. 1221 1258 * Restrict to the amount of data available. 1222 1259 * 1223 1260 * Return the number of bytes copied. 1224 1261 */ 1225 - static unsigned int pl2303_buf_get(struct pl2303_buf *pb, char *buf, 1262 + static unsigned int oti6858_buf_get(struct oti6858_buf *pb, char *buf, 1226 1263 unsigned int count) 1227 1264 { 1228 1265 unsigned int len; ··· 1230 1267 if (pb == NULL) 1231 1268 return 0; 1232 1269 1233 - len = pl2303_buf_data_avail(pb); 1270 + len = oti6858_buf_data_avail(pb); 1234 1271 if (count > len) 1235 1272 count = len; 1236 1273
+58 -54
drivers/usb/serial/pl2303.c
··· 65 65 { USB_DEVICE(ITEGNO_VENDOR_ID, ITEGNO_PRODUCT_ID_2080) }, 66 66 { USB_DEVICE(MA620_VENDOR_ID, MA620_PRODUCT_ID) }, 67 67 { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID) }, 68 + { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) }, 68 69 { USB_DEVICE(TRIPP_VENDOR_ID, TRIPP_PRODUCT_ID) }, 69 70 { USB_DEVICE(RADIOSHACK_VENDOR_ID, RADIOSHACK_PRODUCT_ID) }, 70 71 { USB_DEVICE(DCU10_VENDOR_ID, DCU10_PRODUCT_ID) }, ··· 85 84 { USB_DEVICE(DATAPILOT_U2_VENDOR_ID, DATAPILOT_U2_PRODUCT_ID) }, 86 85 { USB_DEVICE(BELKIN_VENDOR_ID, BELKIN_PRODUCT_ID) }, 87 86 { USB_DEVICE(ALCOR_VENDOR_ID, ALCOR_PRODUCT_ID) }, 88 - { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_ID) }, 89 87 { USB_DEVICE(WS002IN_VENDOR_ID, WS002IN_PRODUCT_ID) }, 90 88 { USB_DEVICE(COREGA_VENDOR_ID, COREGA_PRODUCT_ID) }, 89 + { USB_DEVICE(HL340_VENDOR_ID, HL340_PRODUCT_ID) }, 90 + { USB_DEVICE(YCCABLE_VENDOR_ID, YCCABLE_PRODUCT_ID) }, 91 91 { } /* Terminating entry */ 92 92 }; 93 93 ··· 99 97 .probe = usb_serial_probe, 100 98 .disconnect = usb_serial_disconnect, 101 99 .id_table = id_table, 100 + .suspend = usb_serial_suspend, 101 + .resume = usb_serial_resume, 102 102 .no_dynamic_id = 1, 103 + .supports_autosuspend = 1, 103 104 }; 104 105 105 106 #define SET_LINE_REQUEST_TYPE 0x21 ··· 315 310 return count; 316 311 } 317 312 313 + static int pl2303_vendor_read(__u16 value, __u16 index, 314 + struct usb_serial *serial, unsigned char *buf) 315 + { 316 + int res = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 317 + VENDOR_READ_REQUEST, VENDOR_READ_REQUEST_TYPE, 318 + value, index, buf, 1, 100); 319 + dbg("0x%x:0x%x:0x%x:0x%x %d - %x", VENDOR_READ_REQUEST_TYPE, 320 + VENDOR_READ_REQUEST, value, index, res, buf[0]); 321 + return res; 322 + } 323 + 324 + static int pl2303_vendor_write(__u16 value, __u16 index, 325 + struct usb_serial *serial) 326 + { 327 + int res = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 328 + VENDOR_WRITE_REQUEST, VENDOR_WRITE_REQUEST_TYPE, 329 + value, index, NULL, 0, 100); 330 + dbg("0x%x:0x%x:0x%x:0x%x %d", VENDOR_WRITE_REQUEST_TYPE, 331 + VENDOR_WRITE_REQUEST, value, index, res); 332 + return res; 333 + } 334 + 318 335 static int pl2303_startup(struct usb_serial *serial) 319 336 { 320 337 struct pl2303_private *priv; 321 338 enum pl2303_type type = type_0; 339 + unsigned char *buf; 322 340 int i; 341 + 342 + buf = kmalloc(10, GFP_KERNEL); 343 + if (buf == NULL) 344 + return -ENOMEM; 323 345 324 346 if (serial->dev->descriptor.bDeviceClass == 0x02) 325 347 type = type_0; ··· 372 340 priv->type = type; 373 341 usb_set_serial_port_data(serial->port[i], priv); 374 342 } 343 + 344 + pl2303_vendor_read(0x8484, 0, serial, buf); 345 + pl2303_vendor_write(0x0404, 0, serial); 346 + pl2303_vendor_read(0x8484, 0, serial, buf); 347 + pl2303_vendor_read(0x8383, 0, serial, buf); 348 + pl2303_vendor_read(0x8484, 0, serial, buf); 349 + pl2303_vendor_write(0x0404, 1, serial); 350 + pl2303_vendor_read(0x8484, 0, serial, buf); 351 + pl2303_vendor_read(0x8383, 0, serial, buf); 352 + pl2303_vendor_write(0, 1, serial); 353 + pl2303_vendor_write(1, 0, serial); 354 + if (type == HX) 355 + pl2303_vendor_write(2, 0x44, serial); 356 + else 357 + pl2303_vendor_write(2, 0x24, serial); 358 + 359 + kfree(buf); 375 360 return 0; 376 361 377 362 cleanup: 363 + kfree(buf); 378 364 for (--i; i>=0; --i) { 379 365 priv = usb_get_serial_port_data(serial->port[i]); 380 366 pl2303_buf_free(priv->buf); ··· 632 582 buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]); 633 583 634 584 if (cflag & CRTSCTS) { 635 - __u16 index; 636 585 if (priv->type == HX) 637 - index = 0x61; 586 + pl2303_vendor_write(0x0, 0x61, serial); 638 587 else 639 - index = 0x41; 640 - i = usb_control_msg(serial->dev, 641 - usb_sndctrlpipe(serial->dev, 0), 642 - VENDOR_WRITE_REQUEST, 643 - VENDOR_WRITE_REQUEST_TYPE, 644 - 0x0, index, NULL, 0, 100); 645 - dbg("0x40:0x1:0x0:0x%x %d", index, i); 588 + pl2303_vendor_write(0x0, 0x41, serial); 646 589 } else { 647 - i = usb_control_msg(serial->dev, 648 - usb_sndctrlpipe(serial->dev, 0), 649 - VENDOR_WRITE_REQUEST, 650 - VENDOR_WRITE_REQUEST_TYPE, 651 - 0x0, 0x0, NULL, 0, 100); 652 - dbg ("0x40:0x1:0x0:0x0 %d", i); 590 + pl2303_vendor_write(0x0, 0x0, serial); 653 591 } 654 592 655 593 /* FIXME: Need to read back resulting baud rate */ ··· 667 629 set_current_state(TASK_INTERRUPTIBLE); 668 630 if (pl2303_buf_data_avail(priv->buf) == 0 || 669 631 timeout == 0 || signal_pending(current) || 670 - !usb_get_intfdata(port->serial->interface)) /* disconnect */ 632 + port->serial->disconnected) 671 633 break; 672 634 spin_unlock_irqrestore(&priv->lock, flags); 673 635 timeout = schedule_timeout(timeout); ··· 716 678 struct ktermios tmp_termios; 717 679 struct usb_serial *serial = port->serial; 718 680 struct pl2303_private *priv = usb_get_serial_port_data(port); 719 - unsigned char *buf; 720 681 int result; 721 682 722 683 dbg("%s - port %d", __FUNCTION__, port->number); ··· 723 686 if (priv->type != HX) { 724 687 usb_clear_halt(serial->dev, port->write_urb->pipe); 725 688 usb_clear_halt(serial->dev, port->read_urb->pipe); 726 - } 727 - 728 - buf = kmalloc(10, GFP_KERNEL); 729 - if (buf==NULL) 730 - return -ENOMEM; 731 - 732 - #define FISH(a,b,c,d) \ 733 - result=usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev,0), \ 734 - b, a, c, d, buf, 1, 100); \ 735 - dbg("0x%x:0x%x:0x%x:0x%x %d - %x",a,b,c,d,result,buf[0]); 736 - 737 - #define SOUP(a,b,c,d) \ 738 - result=usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev,0), \ 739 - b, a, c, d, NULL, 0, 100); \ 740 - dbg("0x%x:0x%x:0x%x:0x%x %d",a,b,c,d,result); 741 - 742 - FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8484, 0); 743 - SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 0x0404, 0); 744 - FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8484, 0); 745 - FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8383, 0); 746 - FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8484, 0); 747 - SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 0x0404, 1); 748 - FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8484, 0); 749 - FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8383, 0); 750 - SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 0, 1); 751 - SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 1, 0); 752 - 753 - if (priv->type == HX) { 754 - /* HX chip */ 755 - SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 2, 0x44); 756 - /* reset upstream data pipes */ 757 - SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 8, 0); 758 - SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 9, 0); 759 689 } else { 760 - SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 2, 0x24); 690 + /* reset upstream data pipes */ 691 + pl2303_vendor_write(8, 0, serial); 692 + pl2303_vendor_write(9, 0, serial); 761 693 } 762 - 763 - kfree(buf); 764 694 765 695 /* Setup termios */ 766 696 if (port->tty) {
+9 -4
drivers/usb/serial/pl2303.h
··· 35 35 36 36 #define RATOC_VENDOR_ID 0x0584 37 37 #define RATOC_PRODUCT_ID 0xb000 38 + #define RATOC_PRODUCT_ID_USB60F 0xb020 38 39 39 40 #define TRIPP_VENDOR_ID 0x2478 40 41 #define TRIPP_PRODUCT_ID 0x2008 ··· 97 96 #define ALCOR_VENDOR_ID 0x058F 98 97 #define ALCOR_PRODUCT_ID 0x9720 99 98 100 - /* Huawei E620 UMTS/HSDPA card (ID: 12d1:1001) */ 101 - #define HUAWEI_VENDOR_ID 0x12d1 102 - #define HUAWEI_PRODUCT_ID 0x1001 103 - 104 99 /* Willcom WS002IN Data Driver (by NetIndex Inc.) */ 105 100 #define WS002IN_VENDOR_ID 0x11f6 106 101 #define WS002IN_PRODUCT_ID 0x2001 ··· 104 107 /* Corega CG-USBRS232R Serial Adapter */ 105 108 #define COREGA_VENDOR_ID 0x07aa 106 109 #define COREGA_PRODUCT_ID 0x002a 110 + 111 + /* HL HL-340 (ID: 4348:5523) */ 112 + #define HL340_VENDOR_ID 0x4348 113 + #define HL340_PRODUCT_ID 0x5523 114 + 115 + /* Y.C. Cable U.S.A., Inc - USB to RS-232 */ 116 + #define YCCABLE_VENDOR_ID 0x05ad 117 + #define YCCABLE_PRODUCT_ID 0x0fba
+124 -109
drivers/usb/serial/sierra.c
··· 1 1 /* 2 2 USB Driver for Sierra Wireless 3 3 4 - Copyright (C) 2006, 2007 Kevin Lloyd <linux@sierrawireless.com> 4 + Copyright (C) 2006, 2007, 2008 Kevin Lloyd <linux@sierrawireless.com> 5 5 6 6 IMPORTANT DISCLAIMER: This driver is not commercially supported by 7 7 Sierra Wireless. Use at your own risk. ··· 14 14 Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org> 15 15 */ 16 16 17 - #define DRIVER_VERSION "v.1.2.5b" 17 + #define DRIVER_VERSION "v.1.2.7" 18 18 #define DRIVER_AUTHOR "Kevin Lloyd <linux@sierrawireless.com>" 19 19 #define DRIVER_DESC "USB Driver for Sierra Wireless USB modems" 20 20 ··· 26 26 #include <linux/module.h> 27 27 #include <linux/usb.h> 28 28 #include <linux/usb/serial.h> 29 + #include <linux/usb/ch9.h> 29 30 31 + #define SWIMS_USB_REQUEST_SetPower 0x00 32 + #define SWIMS_USB_REQUEST_SetNmea 0x07 30 33 #define SWIMS_USB_REQUEST_SetMode 0x0B 31 - #define SWIMS_USB_REQUEST_TYPE_SetMode 0x40 32 - #define SWIMS_USB_INDEX_SetMode 0x0000 34 + #define SWIMS_USB_REQUEST_TYPE_VSC_SET 0x40 33 35 #define SWIMS_SET_MODE_Modem 0x0001 34 36 35 37 /* per port private data */ ··· 40 38 #define IN_BUFLEN 4096 41 39 42 40 static int debug; 41 + static int nmea; 42 + static int truinstall = 1; 43 43 44 44 enum devicetype { 45 45 DEVICE_3_PORT = 0, ··· 54 50 int result; 55 51 dev_dbg(&udev->dev, "%s", "SET POWER STATE\n"); 56 52 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 57 - 0x00, /* __u8 request */ 58 - 0x40, /* __u8 request type */ 59 - swiState, /* __u16 value */ 60 - 0, /* __u16 index */ 61 - NULL, /* void *data */ 62 - 0, /* __u16 size */ 63 - USB_CTRL_SET_TIMEOUT); /* int timeout */ 53 + SWIMS_USB_REQUEST_SetPower, /* __u8 request */ 54 + SWIMS_USB_REQUEST_TYPE_VSC_SET, /* __u8 request type */ 55 + swiState, /* __u16 value */ 56 + 0, /* __u16 index */ 57 + NULL, /* void *data */ 58 + 0, /* __u16 size */ 59 + USB_CTRL_SET_TIMEOUT); /* int timeout */ 64 60 return result; 65 61 } 66 62 67 - static int sierra_set_ms_mode(struct usb_device *udev, __u16 eSocMode) 63 + static int sierra_set_ms_mode(struct usb_device *udev, __u16 eSWocMode) 68 64 { 69 65 int result; 70 66 dev_dbg(&udev->dev, "%s", "DEVICE MODE SWITCH\n"); 71 67 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 72 68 SWIMS_USB_REQUEST_SetMode, /* __u8 request */ 73 - SWIMS_USB_REQUEST_TYPE_SetMode, /* __u8 request type */ 74 - eSocMode, /* __u16 value */ 75 - SWIMS_USB_INDEX_SetMode, /* __u16 index */ 69 + SWIMS_USB_REQUEST_TYPE_VSC_SET, /* __u8 request type */ 70 + eSWocMode, /* __u16 value */ 71 + 0x0000, /* __u16 index */ 76 72 NULL, /* void *data */ 77 73 0, /* __u16 size */ 78 74 USB_CTRL_SET_TIMEOUT); /* int timeout */ 79 75 return result; 80 76 } 81 77 82 - static int sierra_probe(struct usb_interface *iface, 83 - const struct usb_device_id *id) 78 + static int sierra_vsc_set_nmea(struct usb_device *udev, __u16 enable) 84 79 { 85 80 int result; 86 - struct usb_device *udev; 81 + dev_dbg(&udev->dev, "%s", "NMEA Enable sent\n"); 82 + result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 83 + SWIMS_USB_REQUEST_SetNmea, /* __u8 request */ 84 + SWIMS_USB_REQUEST_TYPE_VSC_SET, /* __u8 request type */ 85 + enable, /* __u16 value */ 86 + 0x0000, /* __u16 index */ 87 + NULL, /* void *data */ 88 + 0, /* __u16 size */ 89 + USB_CTRL_SET_TIMEOUT); /* int timeout */ 90 + return result; 91 + } 87 92 88 - udev = usb_get_dev(interface_to_usbdev(iface)); 93 + static int sierra_calc_num_ports(struct usb_serial *serial) 94 + { 95 + int result; 96 + int *num_ports = usb_get_serial_data(serial); 89 97 90 - /* Check if in installer mode */ 91 - if (id->driver_info == DEVICE_INSTALLER) { 92 - dev_dbg(&udev->dev, "%s", "FOUND DEVICE(SW)\n"); 93 - result = sierra_set_ms_mode(udev, SWIMS_SET_MODE_Modem); 94 - /*We do not want to bind to the device when in installer mode*/ 95 - return -EIO; 98 + result = *num_ports; 99 + 100 + if (result) { 101 + kfree(num_ports); 102 + usb_set_serial_data(serial, NULL); 96 103 } 97 104 98 - return usb_serial_probe(iface, id); 105 + return result; 106 + } 107 + 108 + static int sierra_probe(struct usb_serial *serial, 109 + const struct usb_device_id *id) 110 + { 111 + int result = 0; 112 + struct usb_device *udev; 113 + int *num_ports; 114 + u8 ifnum; 115 + 116 + num_ports = kmalloc(sizeof(*num_ports), GFP_KERNEL); 117 + if (!num_ports) 118 + return -ENOMEM; 119 + 120 + ifnum = serial->interface->cur_altsetting->desc.bInterfaceNumber; 121 + udev = serial->dev; 122 + 123 + /* Check if in installer mode */ 124 + if (truinstall && id->driver_info == DEVICE_INSTALLER) { 125 + dev_dbg(&udev->dev, "%s", "FOUND TRU-INSTALL DEVICE(SW)\n"); 126 + result = sierra_set_ms_mode(udev, SWIMS_SET_MODE_Modem); 127 + /* Don't bind to the device when in installer mode */ 128 + kfree(num_ports); 129 + return -EIO; 130 + } else if (id->driver_info == DEVICE_1_PORT) 131 + *num_ports = 1; 132 + else if (ifnum == 0x99) 133 + *num_ports = 0; 134 + else 135 + *num_ports = 3; 136 + /* 137 + * save off our num_ports info so that we can use it in the 138 + * calc_num_ports callback 139 + */ 140 + usb_set_serial_data(serial, (void *)num_ports); 141 + 142 + return result; 99 143 } 100 144 101 145 static struct usb_device_id id_table [] = { ··· 156 104 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ 157 105 { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */ 158 106 { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U */ 107 + { USB_DEVICE(0x1199, 0x0023) }, /* Sierra Wireless AirCard */ 159 108 160 109 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ 161 110 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */ ··· 170 117 { USB_DEVICE(0x1199, 0x6851) }, /* Sierra Wireless AirCard 881 */ 171 118 { USB_DEVICE(0x1199, 0x6852) }, /* Sierra Wireless AirCard 880 E */ 172 119 { USB_DEVICE(0x1199, 0x6853) }, /* Sierra Wireless AirCard 881 E */ 120 + { USB_DEVICE(0x1199, 0x6855) }, /* Sierra Wireless AirCard 880 U */ 121 + { USB_DEVICE(0x1199, 0x6856) }, /* Sierra Wireless AirCard 881 U */ 122 + 123 + { USB_DEVICE(0x1199, 0x6468) }, /* Sierra Wireless MP3G - EVDO */ 124 + { USB_DEVICE(0x1199, 0x6469) }, /* Sierra Wireless MP3G - UMTS/HSPA */ 173 125 174 126 { USB_DEVICE(0x1199, 0x0112), .driver_info = DEVICE_1_PORT }, /* Sierra Wireless AirCard 580 */ 175 127 { USB_DEVICE(0x0F3D, 0x0112), .driver_info = DEVICE_1_PORT }, /* Airprime/Sierra PC 5220 */ 128 + { USB_DEVICE(0x05C6, 0x6613), .driver_info = DEVICE_1_PORT }, /* Onda H600/ZTE MF330 */ 176 129 177 130 { USB_DEVICE(0x1199, 0x0FFF), .driver_info = DEVICE_INSTALLER}, 178 131 { } 179 132 }; 180 133 MODULE_DEVICE_TABLE(usb, id_table); 181 134 182 - static struct usb_device_id id_table_1port [] = { 183 - { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */ 184 - { USB_DEVICE(0x0F3D, 0x0112) }, /* AirPrime/Sierra PC 5220 */ 185 - { } 186 - }; 187 - 188 - static struct usb_device_id id_table_3port [] = { 189 - { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */ 190 - { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */ 191 - { USB_DEVICE(0x0f30, 0x1b1d) }, /* Sierra Wireless MC5720 */ 192 - { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */ 193 - { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ 194 - { USB_DEVICE(0x1199, 0x0220) }, /* Sierra Wireless MC5725 */ 195 - { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ 196 - { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */ 197 - { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U*/ 198 - 199 - { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ 200 - { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */ 201 - { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */ 202 - { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 & AC 875U */ 203 - { USB_DEVICE(0x1199, 0x6813) }, /* Sierra Wireless MC8775 (Thinkpad internal) */ 204 - { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */ 205 - { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780*/ 206 - { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781*/ 207 - { USB_DEVICE(0x1199, 0x6850) }, /* Sierra Wireless AirCard 880 */ 208 - { USB_DEVICE(0x1199, 0x6851) }, /* Sierra Wireless AirCard 881 */ 209 - { USB_DEVICE(0x1199, 0x6852) }, /* Sierra Wireless AirCard 880E */ 210 - { USB_DEVICE(0x1199, 0x6853) }, /* Sierra Wireless AirCard 881E */ 211 - { } 212 - }; 213 - 214 135 static struct usb_driver sierra_driver = { 215 136 .name = "sierra", 216 - .probe = sierra_probe, 137 + .probe = usb_serial_probe, 217 138 .disconnect = usb_serial_disconnect, 218 139 .id_table = id_table, 219 140 .no_dynamic_id = 1, 220 141 }; 221 - 222 142 223 143 struct sierra_port_private { 224 144 spinlock_t lock; /* lock the structure */ ··· 214 188 { 215 189 struct usb_serial *serial = port->serial; 216 190 struct sierra_port_private *portdata; 191 + __u16 interface = 0; 217 192 218 193 dbg("%s", __FUNCTION__); 219 194 ··· 227 200 if (portdata->rts_state) 228 201 val |= 0x02; 229 202 203 + /* Determine which port is targeted */ 204 + if (port->bulk_out_endpointAddress == 2) 205 + interface = 0; 206 + else if (port->bulk_out_endpointAddress == 4) 207 + interface = 1; 208 + else if (port->bulk_out_endpointAddress == 5) 209 + interface = 2; 210 + 230 211 return usb_control_msg(serial->dev, 231 212 usb_rcvctrlpipe(serial->dev, 0), 232 - 0x22,0x21,val,0,NULL,0,USB_CTRL_SET_TIMEOUT); 213 + 0x22, 0x21, val, interface, 214 + NULL, 0, USB_CTRL_SET_TIMEOUT); 233 215 } 234 216 235 217 return 0; ··· 597 561 portdata->dtr_state = 0; 598 562 599 563 if (serial->dev) { 600 - sierra_send_setup(port); 564 + mutex_lock(&serial->disc_mutex); 565 + if (!serial->disconnected) 566 + sierra_send_setup(port); 567 + mutex_unlock(&serial->disc_mutex); 601 568 602 569 /* Stop reading/writing urbs */ 603 570 for (i = 0; i < N_IN_URB; i++) ··· 622 583 623 584 dbg("%s", __FUNCTION__); 624 585 625 - /*Set Device mode to D0 */ 586 + /* Set Device mode to D0 */ 626 587 sierra_set_power_state(serial->dev, 0x0000); 588 + 589 + /* Check NMEA and set */ 590 + if (nmea) 591 + sierra_vsc_set_nmea(serial->dev, 1); 627 592 628 593 /* Now setup per port private data */ 629 594 for (i = 0; i < serial->num_ports; i++) { ··· 689 646 } 690 647 } 691 648 692 - static struct usb_serial_driver sierra_1port_device = { 649 + static struct usb_serial_driver sierra_device = { 693 650 .driver = { 694 651 .owner = THIS_MODULE, 695 652 .name = "sierra1", 696 653 }, 697 - .description = "Sierra USB modem (1 port)", 698 - .id_table = id_table_1port, 654 + .description = "Sierra USB modem", 655 + .id_table = id_table, 699 656 .usb_driver = &sierra_driver, 700 657 .num_interrupt_in = NUM_DONT_CARE, 701 - .num_bulk_in = 1, 702 - .num_bulk_out = 1, 703 - .num_ports = 1, 704 - .open = sierra_open, 705 - .close = sierra_close, 706 - .write = sierra_write, 707 - .write_room = sierra_write_room, 708 - .chars_in_buffer = sierra_chars_in_buffer, 709 - .throttle = sierra_rx_throttle, 710 - .unthrottle = sierra_rx_unthrottle, 711 - .ioctl = sierra_ioctl, 712 - .set_termios = sierra_set_termios, 713 - .break_ctl = sierra_break_ctl, 714 - .tiocmget = sierra_tiocmget, 715 - .tiocmset = sierra_tiocmset, 716 - .attach = sierra_startup, 717 - .shutdown = sierra_shutdown, 718 - .read_int_callback = sierra_instat_callback, 719 - }; 720 - 721 - static struct usb_serial_driver sierra_3port_device = { 722 - .driver = { 723 - .owner = THIS_MODULE, 724 - .name = "sierra3", 725 - }, 726 - .description = "Sierra USB modem (3 port)", 727 - .id_table = id_table_3port, 728 - .usb_driver = &sierra_driver, 729 - .num_interrupt_in = NUM_DONT_CARE, 730 - .num_bulk_in = 3, 731 - .num_bulk_out = 3, 732 - .num_ports = 3, 658 + .num_bulk_in = NUM_DONT_CARE, 659 + .num_bulk_out = NUM_DONT_CARE, 660 + .calc_num_ports = sierra_calc_num_ports, 661 + .probe = sierra_probe, 733 662 .open = sierra_open, 734 663 .close = sierra_close, 735 664 .write = sierra_write, ··· 723 708 static int __init sierra_init(void) 724 709 { 725 710 int retval; 726 - retval = usb_serial_register(&sierra_1port_device); 711 + retval = usb_serial_register(&sierra_device); 727 712 if (retval) 728 - goto failed_1port_device_register; 729 - retval = usb_serial_register(&sierra_3port_device); 730 - if (retval) 731 - goto failed_3port_device_register; 713 + goto failed_device_register; 732 714 733 715 734 716 retval = usb_register(&sierra_driver); ··· 737 725 return 0; 738 726 739 727 failed_driver_register: 740 - usb_serial_deregister(&sierra_3port_device); 741 - failed_3port_device_register: 742 - usb_serial_deregister(&sierra_1port_device); 743 - failed_1port_device_register: 728 + usb_serial_deregister(&sierra_device); 729 + failed_device_register: 744 730 return retval; 745 731 } 746 732 747 733 static void __exit sierra_exit(void) 748 734 { 749 735 usb_deregister (&sierra_driver); 750 - usb_serial_deregister(&sierra_1port_device); 751 - usb_serial_deregister(&sierra_3port_device); 736 + usb_serial_deregister(&sierra_device); 752 737 } 753 738 754 739 module_init(sierra_init); ··· 755 746 MODULE_DESCRIPTION(DRIVER_DESC); 756 747 MODULE_VERSION(DRIVER_VERSION); 757 748 MODULE_LICENSE("GPL"); 749 + 750 + module_param(truinstall, bool, 0); 751 + MODULE_PARM_DESC(truinstall, "TRU-Install support"); 752 + 753 + module_param(nmea, bool, 0); 754 + MODULE_PARM_DESC(nmea, "NMEA streaming"); 758 755 759 756 #ifdef CONFIG_USB_DEBUG 760 757 module_param(debug, bool, S_IRUGO | S_IWUSR);
+37 -38
drivers/usb/serial/ti_usb_3410_5052.c
··· 80 80 #include <linux/ioctl.h> 81 81 #include <linux/serial.h> 82 82 #include <linux/circ_buf.h> 83 + #include <linux/mutex.h> 83 84 #include <asm/uaccess.h> 84 85 #include <asm/semaphore.h> 85 86 #include <linux/usb.h> ··· 140 139 }; 141 140 142 141 struct ti_device { 143 - struct semaphore td_open_close_sem; 142 + struct mutex td_open_close_lock; 144 143 int td_open_port_count; 145 144 struct usb_serial *td_serial; 146 145 int td_is_3410; ··· 425 424 dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__); 426 425 return -ENOMEM; 427 426 } 428 - sema_init(&tdev->td_open_close_sem, 1); 427 + mutex_init(&tdev->td_open_close_lock); 429 428 tdev->td_serial = serial; 430 429 usb_set_serial_data(serial, tdev); 431 430 ··· 548 547 tdev = tport->tp_tdev; 549 548 550 549 /* only one open on any port on a device at a time */ 551 - if (down_interruptible(&tdev->td_open_close_sem)) 550 + if (mutex_lock_interruptible(&tdev->td_open_close_lock)) 552 551 return -ERESTARTSYS; 553 552 554 553 if (port->tty) ··· 569 568 if (!urb) { 570 569 dev_err(&port->dev, "%s - no interrupt urb\n", __FUNCTION__); 571 570 status = -EINVAL; 572 - goto up_sem; 571 + goto release_lock; 573 572 } 574 573 urb->complete = ti_interrupt_callback; 575 574 urb->context = tdev; ··· 577 576 status = usb_submit_urb(urb, GFP_KERNEL); 578 577 if (status) { 579 578 dev_err(&port->dev, "%s - submit interrupt urb failed, %d\n", __FUNCTION__, status); 580 - goto up_sem; 579 + goto release_lock; 581 580 } 582 581 } 583 582 584 - ti_set_termios(port, NULL); 583 + ti_set_termios(port, port->tty->termios); 585 584 586 585 dbg("%s - sending TI_OPEN_PORT", __FUNCTION__); 587 586 status = ti_command_out_sync(tdev, TI_OPEN_PORT, ··· 618 617 usb_clear_halt(dev, port->write_urb->pipe); 619 618 usb_clear_halt(dev, port->read_urb->pipe); 620 619 621 - ti_set_termios(port, NULL); 620 + ti_set_termios(port, port->tty->termios); 622 621 623 622 dbg("%s - sending TI_OPEN_PORT (2)", __FUNCTION__); 624 623 status = ti_command_out_sync(tdev, TI_OPEN_PORT, ··· 657 656 tport->tp_is_open = 1; 658 657 ++tdev->td_open_port_count; 659 658 660 - goto up_sem; 659 + goto release_lock; 661 660 662 661 unlink_int_urb: 663 662 if (tdev->td_open_port_count == 0) 664 663 usb_kill_urb(port->serial->port[0]->interrupt_in_urb); 665 - up_sem: 666 - up(&tdev->td_open_close_sem); 664 + release_lock: 665 + mutex_unlock(&tdev->td_open_close_lock); 667 666 dbg("%s - exit %d", __FUNCTION__, status); 668 667 return status; 669 668 } ··· 675 674 struct ti_port *tport; 676 675 int port_number; 677 676 int status; 678 - int do_up; 677 + int do_unlock; 679 678 680 679 dbg("%s - port %d", __FUNCTION__, port->number); 681 680 ··· 700 699 if (status) 701 700 dev_err(&port->dev, "%s - cannot send close port command, %d\n" , __FUNCTION__, status); 702 701 703 - /* if down is interrupted, continue anyway */ 704 - do_up = !down_interruptible(&tdev->td_open_close_sem); 702 + /* if mutex_lock is interrupted, continue anyway */ 703 + do_unlock = !mutex_lock_interruptible(&tdev->td_open_close_lock); 705 704 --tport->tp_tdev->td_open_port_count; 706 705 if (tport->tp_tdev->td_open_port_count <= 0) { 707 706 /* last port is closed, shut down interrupt urb */ 708 707 usb_kill_urb(port->serial->port[0]->interrupt_in_urb); 709 708 tport->tp_tdev->td_open_port_count = 0; 710 709 } 711 - if (do_up) 712 - up(&tdev->td_open_close_sem); 710 + if (do_unlock) 711 + mutex_unlock(&tdev->td_open_close_lock); 713 712 714 713 dbg("%s - exit", __FUNCTION__); 715 714 } ··· 897 896 898 897 dbg("%s - port %d", __FUNCTION__, port->number); 899 898 900 - if (!tty || !tty->termios) { 901 - dbg("%s - no tty or termios", __FUNCTION__); 902 - return; 903 - } 904 - 905 899 cflag = tty->termios->c_cflag; 906 900 iflag = tty->termios->c_iflag; 907 901 908 - if (old_termios && cflag == old_termios->c_cflag 909 - && iflag == old_termios->c_iflag) { 910 - dbg("%s - nothing to change", __FUNCTION__); 911 - return; 912 - } 913 - 914 - dbg("%s - clfag %08x, iflag %08x", __FUNCTION__, cflag, iflag); 915 - 916 - if (old_termios) 917 - dbg("%s - old clfag %08x, old iflag %08x", __FUNCTION__, old_termios->c_cflag, old_termios->c_iflag); 902 + dbg("%s - cflag %08x, iflag %08x", __FUNCTION__, cflag, iflag); 903 + dbg("%s - old clfag %08x, old iflag %08x", __FUNCTION__, old_termios->c_cflag, old_termios->c_iflag); 918 904 919 905 if (tport == NULL) 920 906 return; ··· 934 946 config->bDataBits = TI_UART_8_DATA_BITS; 935 947 break; 936 948 } 949 + 950 + /* CMSPAR isn't supported by this driver */ 951 + tty->termios->c_cflag &= ~CMSPAR; 937 952 938 953 if (cflag & PARENB) { 939 954 if (cflag & PARODD) { ··· 980 989 } 981 990 982 991 baud = tty_get_baud_rate(tty); 983 - if (!baud) baud = 9600; 992 + if (!baud) 993 + baud = 9600; 984 994 if (tport->tp_tdev->td_is_3410) 985 995 config->wBaudRate = (__u16)((923077 + baud/2) / baud); 986 996 else 987 997 config->wBaudRate = (__u16)((461538 + baud/2) / baud); 998 + 999 + /* FIXME: Should calculate resulting baud here and report it back */ 1000 + if ((cflag & CBAUD) != B0) 1001 + tty_encode_baud_rate(tty, baud, baud); 988 1002 989 1003 dbg("%s - BaudRate=%d, wBaudRate=%d, wFlags=0x%04X, bDataBits=%d, bParity=%d, bStopBits=%d, cXon=%d, cXoff=%d, bUartMode=%d", 990 1004 __FUNCTION__, baud, config->wBaudRate, config->wFlags, config->bDataBits, config->bParity, config->bStopBits, config->cXon, config->cXoff, config->bUartMode); ··· 1493 1497 struct ti_device *tdev = tport->tp_tdev; 1494 1498 struct usb_serial_port *port = tport->tp_port; 1495 1499 wait_queue_t wait; 1496 - unsigned long flags; 1497 1500 1498 1501 dbg("%s - port %d", __FUNCTION__, port->number); 1499 1502 1500 - spin_lock_irqsave(&tport->tp_lock, flags); 1503 + spin_lock_irq(&tport->tp_lock); 1501 1504 1502 1505 /* wait for data to drain from the buffer */ 1503 1506 tdev->td_urb_error = 0; ··· 1507 1512 if (ti_buf_data_avail(tport->tp_write_buf) == 0 1508 1513 || timeout == 0 || signal_pending(current) 1509 1514 || tdev->td_urb_error 1510 - || !usb_get_intfdata(port->serial->interface)) /* disconnect */ 1515 + || port->serial->disconnected) /* disconnect */ 1511 1516 break; 1512 - spin_unlock_irqrestore(&tport->tp_lock, flags); 1517 + spin_unlock_irq(&tport->tp_lock); 1513 1518 timeout = schedule_timeout(timeout); 1514 - spin_lock_irqsave(&tport->tp_lock, flags); 1519 + spin_lock_irq(&tport->tp_lock); 1515 1520 } 1516 1521 set_current_state(TASK_RUNNING); 1517 1522 remove_wait_queue(&tport->tp_write_wait, &wait); ··· 1520 1525 if (flush) 1521 1526 ti_buf_clear(tport->tp_write_buf); 1522 1527 1523 - spin_unlock_irqrestore(&tport->tp_lock, flags); 1528 + spin_unlock_irq(&tport->tp_lock); 1524 1529 1530 + mutex_lock(&port->serial->disc_mutex); 1525 1531 /* wait for data to drain from the device */ 1526 1532 /* wait for empty tx register, plus 20 ms */ 1527 1533 timeout += jiffies; 1528 1534 tport->tp_lsr &= ~TI_LSR_TX_EMPTY; 1529 1535 while ((long)(jiffies - timeout) < 0 && !signal_pending(current) 1530 1536 && !(tport->tp_lsr&TI_LSR_TX_EMPTY) && !tdev->td_urb_error 1531 - && usb_get_intfdata(port->serial->interface)) { /* not disconnected */ 1537 + && !port->serial->disconnected) { 1532 1538 if (ti_get_lsr(tport)) 1533 1539 break; 1540 + mutex_unlock(&port->serial->disc_mutex); 1534 1541 msleep_interruptible(20); 1542 + mutex_lock(&port->serial->disc_mutex); 1535 1543 } 1544 + mutex_unlock(&port->serial->disc_mutex); 1536 1545 } 1537 1546 1538 1547
+26 -16
drivers/usb/serial/usb-serial.c
··· 225 225 goto bailout_mutex_unlock; 226 226 } 227 227 228 + retval = usb_autopm_get_interface(serial->interface); 229 + if (retval) 230 + goto bailout_module_put; 228 231 /* only call the device specific open if this 229 232 * is the first time the port is opened */ 230 233 retval = serial->type->open(port, filp); 231 234 if (retval) 232 - goto bailout_module_put; 235 + goto bailout_interface_put; 233 236 } 234 237 235 238 mutex_unlock(&port->mutex); 236 239 return 0; 237 240 241 + bailout_interface_put: 242 + usb_autopm_put_interface(serial->interface); 238 243 bailout_module_put: 239 244 module_put(serial->type->driver.owner); 240 245 bailout_mutex_unlock: ··· 269 264 } 270 265 271 266 --port->open_count; 272 - if (port->open_count == 0) { 267 + if (port->open_count == 0) 273 268 /* only call the device specific close if this 274 269 * port is being closed by the last owner */ 275 270 port->serial->type->close(port, filp); 276 271 272 + if (port->open_count == (port->console? 1 : 0)) { 277 273 if (port->tty) { 278 274 if (port->tty->driver_data) 279 275 port->tty->driver_data = NULL; 280 276 port->tty = NULL; 281 277 } 278 + } 282 279 280 + if (port->open_count == 0) { 281 + usb_autopm_put_interface(port->serial->interface); 283 282 module_put(port->serial->type->driver.owner); 284 283 } 285 284 ··· 634 625 serial->type = driver; 635 626 serial->interface = interface; 636 627 kref_init(&serial->kref); 628 + mutex_init(&serial->disc_mutex); 637 629 638 630 return serial; 639 631 } ··· 1090 1080 usb_serial_console_disconnect(serial); 1091 1081 dbg ("%s", __FUNCTION__); 1092 1082 1083 + mutex_lock(&serial->disc_mutex); 1093 1084 usb_set_intfdata (interface, NULL); 1094 - if (serial) { 1095 - for (i = 0; i < serial->num_ports; ++i) { 1096 - port = serial->port[i]; 1097 - if (port) { 1098 - if (port->tty) 1099 - tty_hangup(port->tty); 1100 - kill_traffic(port); 1101 - } 1085 + /* must set a flag, to signal subdrivers */ 1086 + serial->disconnected = 1; 1087 + for (i = 0; i < serial->num_ports; ++i) { 1088 + port = serial->port[i]; 1089 + if (port) { 1090 + if (port->tty) 1091 + tty_hangup(port->tty); 1092 + kill_traffic(port); 1102 1093 } 1103 - /* let the last holder of this object 1104 - * cause it to be cleaned up */ 1105 - usb_serial_put(serial); 1106 1094 } 1095 + /* let the last holder of this object 1096 + * cause it to be cleaned up */ 1097 + mutex_unlock(&serial->disc_mutex); 1098 + usb_serial_put(serial); 1107 1099 dev_info(dev, "device disconnected\n"); 1108 1100 } 1109 1101 ··· 1114 1102 struct usb_serial *serial = usb_get_intfdata(intf); 1115 1103 struct usb_serial_port *port; 1116 1104 int i, r = 0; 1117 - 1118 - if (!serial) /* device has been disconnected */ 1119 - return 0; 1120 1105 1121 1106 for (i = 0; i < serial->num_ports; ++i) { 1122 1107 port = serial->port[i]; ··· 1262 1253 set_to_generic_if_null(device, read_bulk_callback); 1263 1254 set_to_generic_if_null(device, write_bulk_callback); 1264 1255 set_to_generic_if_null(device, shutdown); 1256 + set_to_generic_if_null(device, resume); 1265 1257 } 1266 1258 1267 1259 int usb_serial_register(struct usb_serial_driver *driver) /* must be called with BKL held */
+13 -9
drivers/usb/serial/visor.c
··· 349 349 usb_kill_urb(port->read_urb); 350 350 usb_kill_urb(port->interrupt_in_urb); 351 351 352 - /* Try to send shutdown message, if the device is gone, this will just fail. */ 353 - transfer_buffer = kmalloc (0x12, GFP_KERNEL); 354 - if (transfer_buffer) { 355 - usb_control_msg (port->serial->dev, 356 - usb_rcvctrlpipe(port->serial->dev, 0), 357 - VISOR_CLOSE_NOTIFICATION, 0xc2, 358 - 0x0000, 0x0000, 359 - transfer_buffer, 0x12, 300); 360 - kfree (transfer_buffer); 352 + mutex_lock(&port->serial->disc_mutex); 353 + if (!port->serial->disconnected) { 354 + /* Try to send shutdown message, unless the device is gone */ 355 + transfer_buffer = kmalloc (0x12, GFP_KERNEL); 356 + if (transfer_buffer) { 357 + usb_control_msg (port->serial->dev, 358 + usb_rcvctrlpipe(port->serial->dev, 0), 359 + VISOR_CLOSE_NOTIFICATION, 0xc2, 360 + 0x0000, 0x0000, 361 + transfer_buffer, 0x12, 300); 362 + kfree (transfer_buffer); 363 + } 361 364 } 365 + mutex_unlock(&port->serial->disc_mutex); 362 366 363 367 if (stats) 364 368 dev_info(&port->dev, "Bytes In = %d Bytes Out = %d\n",
+6 -4
drivers/usb/serial/whiteheat.c
··· 610 610 if (retval) 611 611 goto exit; 612 612 613 - if (port->tty) 614 - port->tty->low_latency = 1; 613 + port->tty->low_latency = 1; 615 614 616 615 /* send an open port command */ 617 616 retval = firm_open(port); ··· 658 659 struct list_head *tmp2; 659 660 660 661 dbg("%s - port %d", __FUNCTION__, port->number); 661 - 662 + 663 + mutex_lock(&port->serial->disc_mutex); 662 664 /* filp is NULL when called from usb_serial_disconnect */ 663 - if (filp && (tty_hung_up_p(filp))) { 665 + if ((filp && (tty_hung_up_p(filp))) || port->serial->disconnected) { 666 + mutex_unlock(&port->serial->disc_mutex); 664 667 return; 665 668 } 669 + mutex_unlock(&port->serial->disc_mutex); 666 670 667 671 port->tty->closing = 1; 668 672
+2 -1
drivers/usb/storage/initializers.c
··· 66 66 { 67 67 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap*) us->iobuf; 68 68 struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap*) us->iobuf; 69 - int res, partial; 69 + int res; 70 + unsigned int partial; 70 71 static char init_string[] = "\xec\x0a\x06\x00$PCCHIPS"; 71 72 72 73 US_DEBUGP("Sending UCR-61S2B initialization packet...\n");
+14 -15
drivers/usb/storage/isd200.c
··· 48 48 #include <linux/errno.h> 49 49 #include <linux/slab.h> 50 50 #include <linux/hdreg.h> 51 - #include <linux/ide.h> 52 51 #include <linux/scatterlist.h> 53 52 54 53 #include <scsi/scsi.h> ··· 108 109 #define REG_DEVICE_HEAD 0x40 109 110 #define REG_STATUS 0x80 110 111 #define REG_COMMAND 0x80 112 + 113 + /* ATA registers offset definitions */ 114 + #define ATA_REG_ERROR_OFFSET 1 115 + #define ATA_REG_LCYL_OFFSET 4 116 + #define ATA_REG_HCYL_OFFSET 5 117 + #define ATA_REG_STATUS_OFFSET 7 111 118 112 119 /* ATA error definitions not in <linux/hdreg.h> */ 113 120 #define ATA_ERROR_MEDIA_CHANGE 0x20 ··· 365 360 { 366 361 struct isd200_info *info = (struct isd200_info *)us->extra; 367 362 struct sense_data *buf = (struct sense_data *) &srb->sense_buffer[0]; 368 - unsigned char error = info->ATARegs[IDE_ERROR_OFFSET]; 363 + unsigned char error = info->ATARegs[ATA_REG_ERROR_OFFSET]; 369 364 370 365 if(error & ATA_ERROR_MEDIA_CHANGE) { 371 366 buf->ErrorCode = 0x70 | SENSE_ERRCODE_VALID; ··· 554 549 retStatus = ISD200_ERROR; 555 550 } else { 556 551 memcpy(info->ATARegs, info->RegsBuf, sizeof(info->ATARegs)); 557 - US_DEBUGP(" Got ATA Register[IDE_ERROR_OFFSET] = 0x%x\n", 558 - info->ATARegs[IDE_ERROR_OFFSET]); 552 + US_DEBUGP(" Got ATA Register[ATA_REG_ERROR_OFFSET] = 0x%x\n", 553 + info->ATARegs[ATA_REG_ERROR_OFFSET]); 559 554 } 560 555 561 556 return retStatus; ··· 897 892 break; 898 893 899 894 if (!detect) { 900 - if (regs[IDE_STATUS_OFFSET] & BUSY_STAT ) { 895 + if (regs[ATA_REG_STATUS_OFFSET] & BUSY_STAT) { 901 896 US_DEBUGP(" %s status is still BSY, try again...\n",mstr); 902 897 } else { 903 898 US_DEBUGP(" %s status !BSY, continue with next operation\n",mstr); ··· 907 902 /* check for BUSY_STAT and */ 908 903 /* WRERR_STAT (workaround ATA Zip drive) and */ 909 904 /* ERR_STAT (workaround for Archos CD-ROM) */ 910 - else if (regs[IDE_STATUS_OFFSET] & 905 + else if (regs[ATA_REG_STATUS_OFFSET] & 911 906 (BUSY_STAT | WRERR_STAT | ERR_STAT )) { 912 907 US_DEBUGP(" Status indicates it is not ready, try again...\n"); 913 908 } 914 909 /* check for DRDY, ATA devices set DRDY after SRST */ 915 - else if (regs[IDE_STATUS_OFFSET] & READY_STAT) { 910 + else if (regs[ATA_REG_STATUS_OFFSET] & READY_STAT) { 916 911 US_DEBUGP(" Identified ATA device\n"); 917 912 info->DeviceFlags |= DF_ATA_DEVICE; 918 913 info->DeviceHead = master_slave; ··· 921 916 /* check Cylinder High/Low to 922 917 determine if it is an ATAPI device 923 918 */ 924 - else if ((regs[IDE_HCYL_OFFSET] == 0xEB) && 925 - (regs[IDE_LCYL_OFFSET] == 0x14)) { 919 + else if (regs[ATA_REG_HCYL_OFFSET] == 0xEB && 920 + regs[ATA_REG_LCYL_OFFSET] == 0x14) { 926 921 /* It seems that the RICOH 927 922 MP6200A CD/RW drive will 928 923 report itself okay as a ··· 1005 1000 US_DEBUGP("Leaving isd200_manual_enum %08X\n", retStatus); 1006 1001 return(retStatus); 1007 1002 } 1008 - 1009 - /* 1010 - * We are the last non IDE user of the legacy IDE ident structures 1011 - * and we thus want to keep a private copy of this function so the 1012 - * driver can be used without the obsolete drivers/ide layer 1013 - */ 1014 1003 1015 1004 static void isd200_fix_driveid (struct hd_driveid *id) 1016 1005 {
+8
drivers/usb/storage/unusual_devs.h
··· 86 86 US_SC_8070, US_PR_USBAT, init_usbat_cd, 0), 87 87 #endif 88 88 89 + /* Reported by Grant Grundler <grundler@parisc-linux.org> 90 + * HP r707 camera in "Disk" mode with 2.00.23 or 2.00.24 firmware. 91 + */ 92 + UNUSUAL_DEV( 0x03f0, 0x4002, 0x0001, 0x0001, 93 + "HP", 94 + "PhotoSmart R707", 95 + US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_FIX_CAPACITY), 96 + 89 97 /* Reported by Sebastian Kapfer <sebastian_kapfer@gmx.net> 90 98 * and Olaf Hering <olh@suse.de> (different bcd's, same vendor/product) 91 99 * for USB floppies that need the SINGLE_LUN enforcement.
-8
drivers/video/sis/sis.h
··· 39 39 #include <linux/spinlock.h> 40 40 41 41 #ifdef CONFIG_COMPAT 42 - #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,10) 43 - #include <linux/ioctl32.h> 44 - #define SIS_OLD_CONFIG_COMPAT 45 - #else 46 42 #define SIS_NEW_CONFIG_COMPAT 47 - #endif 48 43 #endif /* CONFIG_COMPAT */ 49 44 50 45 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,8) ··· 602 607 int haveXGIROM; 603 608 int registered; 604 609 int warncount; 605 - #ifdef SIS_OLD_CONFIG_COMPAT 606 - int ioctl32registered; 607 - #endif 608 610 609 611 int sisvga_engine; 610 612 int hwcursor_size;
-48
drivers/video/sis/sis_main.c
··· 5805 5805 ivideo->pcifunc = PCI_FUNC(pdev->devfn); 5806 5806 ivideo->subsysvendor = pdev->subsystem_vendor; 5807 5807 ivideo->subsysdevice = pdev->subsystem_device; 5808 - #ifdef SIS_OLD_CONFIG_COMPAT 5809 - ivideo->ioctl32registered = 0; 5810 - #endif 5811 5808 5812 5809 #ifndef MODULE 5813 5810 if(sisfb_mode_idx == -1) { ··· 6417 6420 ivideo->next = card_list; 6418 6421 card_list = ivideo; 6419 6422 6420 - #ifdef SIS_OLD_CONFIG_COMPAT 6421 - { 6422 - int ret; 6423 - /* Our ioctls are all "32/64bit compatible" */ 6424 - ret = register_ioctl32_conversion(FBIO_ALLOC, NULL); 6425 - ret |= register_ioctl32_conversion(FBIO_FREE, NULL); 6426 - ret |= register_ioctl32_conversion(FBIOGET_VBLANK, NULL); 6427 - ret |= register_ioctl32_conversion(SISFB_GET_INFO_SIZE, NULL); 6428 - ret |= register_ioctl32_conversion(SISFB_GET_INFO, NULL); 6429 - ret |= register_ioctl32_conversion(SISFB_GET_TVPOSOFFSET, NULL); 6430 - ret |= register_ioctl32_conversion(SISFB_SET_TVPOSOFFSET, NULL); 6431 - ret |= register_ioctl32_conversion(SISFB_SET_LOCK, NULL); 6432 - ret |= register_ioctl32_conversion(SISFB_GET_VBRSTATUS, NULL); 6433 - ret |= register_ioctl32_conversion(SISFB_GET_AUTOMAXIMIZE, NULL); 6434 - ret |= register_ioctl32_conversion(SISFB_SET_AUTOMAXIMIZE, NULL); 6435 - ret |= register_ioctl32_conversion(SISFB_COMMAND, NULL); 6436 - if(ret) 6437 - printk(KERN_ERR 6438 - "sisfb: Error registering ioctl32 translations\n"); 6439 - else 6440 - ivideo->ioctl32registered = 1; 6441 - } 6442 - #endif 6443 - 6444 6423 printk(KERN_INFO "sisfb: 2D acceleration is %s, y-panning %s\n", 6445 6424 ivideo->sisfb_accel ? "enabled" : "disabled", 6446 6425 ivideo->sisfb_ypan ? ··· 6445 6472 struct fb_info *sis_fb_info = ivideo->memyselfandi; 6446 6473 int registered = ivideo->registered; 6447 6474 int modechanged = ivideo->modechanged; 6448 - 6449 - #ifdef SIS_OLD_CONFIG_COMPAT 6450 - if(ivideo->ioctl32registered) { 6451 - int ret; 6452 - ret = unregister_ioctl32_conversion(FBIO_ALLOC); 6453 - ret |= unregister_ioctl32_conversion(FBIO_FREE); 6454 - ret |= unregister_ioctl32_conversion(FBIOGET_VBLANK); 6455 - ret |= unregister_ioctl32_conversion(SISFB_GET_INFO_SIZE); 6456 - ret |= unregister_ioctl32_conversion(SISFB_GET_INFO); 6457 - ret |= unregister_ioctl32_conversion(SISFB_GET_TVPOSOFFSET); 6458 - ret |= unregister_ioctl32_conversion(SISFB_SET_TVPOSOFFSET); 6459 - ret |= unregister_ioctl32_conversion(SISFB_SET_LOCK); 6460 - ret |= unregister_ioctl32_conversion(SISFB_GET_VBRSTATUS); 6461 - ret |= unregister_ioctl32_conversion(SISFB_GET_AUTOMAXIMIZE); 6462 - ret |= unregister_ioctl32_conversion(SISFB_SET_AUTOMAXIMIZE); 6463 - ret |= unregister_ioctl32_conversion(SISFB_COMMAND); 6464 - if(ret) 6465 - printk(KERN_ERR 6466 - "sisfb: Error unregistering ioctl32 translations\n"); 6467 - } 6468 - #endif 6469 6475 6470 6476 /* Unmap */ 6471 6477 iounmap(ivideo->mmio_vbase);
+2 -1
include/asm-arm/arch-at91/board.h
··· 40 40 /* USB Device */ 41 41 struct at91_udc_data { 42 42 u8 vbus_pin; /* high == host powering us */ 43 - u8 pullup_pin; /* high == D+ pulled up */ 43 + u8 pullup_pin; /* active == D+ pulled up */ 44 + u8 pullup_active_low; /* true == pullup_pin is active low */ 44 45 }; 45 46 extern void __init at91_add_device_udc(struct at91_udc_data *data); 46 47
+2
include/asm-arm/mach/udc_pxa2xx.h
··· 19 19 * with on-chip GPIOs not Lubbock's wierd hardware, can have a sane 20 20 * VBUS IRQ and omit the methods above. Store the GPIO number 21 21 * here; for GPIO 0, also mask in one of the pxa_gpio_mode() bits. 22 + * Note that sometimes the signals go through inverters... 22 23 */ 24 + bool gpio_vbus_inverted; 23 25 u16 gpio_vbus; /* high == vbus present */ 24 26 u16 gpio_pullup; /* high == pullup activated */ 25 27 };
+117 -92
include/linux/usb.h
··· 162 162 unsigned needs_remote_wakeup:1; /* driver requires remote wakeup */ 163 163 164 164 struct device dev; /* interface specific device info */ 165 - struct device *usb_dev; /* pointer to the usb class's device, if any */ 165 + struct device *usb_dev; 166 166 int pm_usage_cnt; /* usage counter for autosuspend */ 167 167 }; 168 168 #define to_usb_interface(d) container_of(d, struct usb_interface, dev) 169 169 #define interface_to_usbdev(intf) \ 170 170 container_of(intf->dev.parent, struct usb_device, dev) 171 171 172 - static inline void *usb_get_intfdata (struct usb_interface *intf) 172 + static inline void *usb_get_intfdata(struct usb_interface *intf) 173 173 { 174 - return dev_get_drvdata (&intf->dev); 174 + return dev_get_drvdata(&intf->dev); 175 175 } 176 176 177 - static inline void usb_set_intfdata (struct usb_interface *intf, void *data) 177 + static inline void usb_set_intfdata(struct usb_interface *intf, void *data) 178 178 { 179 179 dev_set_drvdata(&intf->dev, data); 180 180 } ··· 275 275 276 276 int __usb_get_extra_descriptor(char *buffer, unsigned size, 277 277 unsigned char type, void **ptr); 278 - #define usb_get_extra_descriptor(ifpoint,type,ptr)\ 279 - __usb_get_extra_descriptor((ifpoint)->extra,(ifpoint)->extralen,\ 280 - type,(void**)ptr) 278 + #define usb_get_extra_descriptor(ifpoint, type, ptr) \ 279 + __usb_get_extra_descriptor((ifpoint)->extra, \ 280 + (ifpoint)->extralen, \ 281 + type, (void **)ptr) 281 282 282 283 /* ----------------------------------------------------------------------- */ 283 284 ··· 319 318 #ifdef CONFIG_USB_DEVICEFS 320 319 struct dentry *usbfs_dentry; /* usbfs dentry entry for the bus */ 321 320 #endif 322 - struct class_device *class_dev; /* class device for this bus */ 321 + struct device *dev; /* device for this bus */ 323 322 324 323 #if defined(CONFIG_USB_MON) 325 324 struct mon_bus *mon_bus; /* non-null when associated */ ··· 389 388 unsigned can_submit:1; /* URBs may be submitted */ 390 389 unsigned discon_suspended:1; /* Disconnected while suspended */ 391 390 unsigned have_langid:1; /* whether string_langid is valid */ 392 - unsigned authorized:1; /* Policy has determined we can use it */ 391 + unsigned authorized:1; /* Policy has said we can use it */ 393 392 unsigned wusb:1; /* Device is Wireless USB */ 394 393 int string_langid; /* language ID for strings */ 395 394 ··· 418 417 419 418 int pm_usage_cnt; /* usage counter for autosuspend */ 420 419 u32 quirks; /* quirks of the whole device */ 421 - atomic_t urbnum; /* number of URBs submitted for the whole device */ 420 + atomic_t urbnum; /* number of URBs submitted for 421 + the whole device */ 422 + 423 + unsigned long active_duration; /* total time device is not suspended */ 422 424 423 425 #ifdef CONFIG_PM 424 426 struct delayed_work autosuspend; /* for delayed autosuspends */ ··· 429 425 430 426 unsigned long last_busy; /* time of last use */ 431 427 int autosuspend_delay; /* in jiffies */ 428 + unsigned long connect_time; /* time device was first connected */ 432 429 433 430 unsigned auto_pm:1; /* autosuspend/resume in progress */ 434 431 unsigned do_remote_wakeup:1; /* remote wakeup should be enabled */ ··· 503 498 /*-------------------------------------------------------------------------*/ 504 499 505 500 /* for drivers using iso endpoints */ 506 - extern int usb_get_current_frame_number (struct usb_device *usb_dev); 501 + extern int usb_get_current_frame_number(struct usb_device *usb_dev); 507 502 508 503 /* used these for multi-interface device registration */ 509 504 extern int usb_driver_claim_interface(struct usb_driver *driver, 510 - struct usb_interface *iface, void* priv); 505 + struct usb_interface *iface, void *priv); 511 506 512 507 /** 513 508 * usb_interface_claimed - returns true iff an interface is claimed ··· 519 514 * may need to explicitly claim that lock. 520 515 * 521 516 */ 522 - static inline int usb_interface_claimed(struct usb_interface *iface) { 517 + static inline int usb_interface_claimed(struct usb_interface *iface) 518 + { 523 519 return (iface->dev.driver != NULL); 524 520 } 525 521 ··· 563 557 * USB 2.0 root hubs (EHCI host controllers) will get one path ID if they are 564 558 * high speed, and a different one if they are full or low speed. 565 559 */ 566 - static inline int usb_make_path (struct usb_device *dev, char *buf, 567 - size_t size) 560 + static inline int usb_make_path(struct usb_device *dev, char *buf, size_t size) 568 561 { 569 562 int actual; 570 - actual = snprintf (buf, size, "usb-%s-%s", dev->bus->bus_name, 571 - dev->devpath); 563 + actual = snprintf(buf, size, "usb-%s-%s", dev->bus->bus_name, 564 + dev->devpath); 572 565 return (actual >= (int)size) ? -1 : actual; 573 566 } 574 567 ··· 613 608 * 614 609 * Returns true if the endpoint is of type OUT, otherwise it returns false. 615 610 */ 616 - static inline int usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd) 611 + static inline int usb_endpoint_dir_out( 612 + const struct usb_endpoint_descriptor *epd) 617 613 { 618 614 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT); 619 615 } ··· 625 619 * 626 620 * Returns true if the endpoint is of type bulk, otherwise it returns false. 627 621 */ 628 - static inline int usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd) 622 + static inline int usb_endpoint_xfer_bulk( 623 + const struct usb_endpoint_descriptor *epd) 629 624 { 630 625 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 631 626 USB_ENDPOINT_XFER_BULK); ··· 638 631 * 639 632 * Returns true if the endpoint is of type control, otherwise it returns false. 640 633 */ 641 - static inline int usb_endpoint_xfer_control(const struct usb_endpoint_descriptor *epd) 634 + static inline int usb_endpoint_xfer_control( 635 + const struct usb_endpoint_descriptor *epd) 642 636 { 643 637 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 644 638 USB_ENDPOINT_XFER_CONTROL); ··· 652 644 * Returns true if the endpoint is of type interrupt, otherwise it returns 653 645 * false. 654 646 */ 655 - static inline int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd) 647 + static inline int usb_endpoint_xfer_int( 648 + const struct usb_endpoint_descriptor *epd) 656 649 { 657 650 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 658 651 USB_ENDPOINT_XFER_INT); ··· 666 657 * Returns true if the endpoint is of type isochronous, otherwise it returns 667 658 * false. 668 659 */ 669 - static inline int usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd) 660 + static inline int usb_endpoint_xfer_isoc( 661 + const struct usb_endpoint_descriptor *epd) 670 662 { 671 663 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 672 664 USB_ENDPOINT_XFER_ISOC); ··· 680 670 * Returns true if the endpoint has bulk transfer type and IN direction, 681 671 * otherwise it returns false. 682 672 */ 683 - static inline int usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd) 673 + static inline int usb_endpoint_is_bulk_in( 674 + const struct usb_endpoint_descriptor *epd) 684 675 { 685 676 return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd)); 686 677 } ··· 693 682 * Returns true if the endpoint has bulk transfer type and OUT direction, 694 683 * otherwise it returns false. 695 684 */ 696 - static inline int usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd) 685 + static inline int usb_endpoint_is_bulk_out( 686 + const struct usb_endpoint_descriptor *epd) 697 687 { 698 688 return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd)); 699 689 } ··· 706 694 * Returns true if the endpoint has interrupt transfer type and IN direction, 707 695 * otherwise it returns false. 708 696 */ 709 - static inline int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd) 697 + static inline int usb_endpoint_is_int_in( 698 + const struct usb_endpoint_descriptor *epd) 710 699 { 711 700 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd)); 712 701 } ··· 719 706 * Returns true if the endpoint has interrupt transfer type and OUT direction, 720 707 * otherwise it returns false. 721 708 */ 722 - static inline int usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd) 709 + static inline int usb_endpoint_is_int_out( 710 + const struct usb_endpoint_descriptor *epd) 723 711 { 724 712 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd)); 725 713 } ··· 732 718 * Returns true if the endpoint has isochronous transfer type and IN direction, 733 719 * otherwise it returns false. 734 720 */ 735 - static inline int usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd) 721 + static inline int usb_endpoint_is_isoc_in( 722 + const struct usb_endpoint_descriptor *epd) 736 723 { 737 724 return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd)); 738 725 } ··· 745 730 * Returns true if the endpoint has isochronous transfer type and OUT direction, 746 731 * otherwise it returns false. 747 732 */ 748 - static inline int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd) 733 + static inline int usb_endpoint_is_isoc_out( 734 + const struct usb_endpoint_descriptor *epd) 749 735 { 750 736 return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd)); 751 737 } ··· 777 761 * specific device. 778 762 */ 779 763 #define USB_DEVICE(vend,prod) \ 780 - .match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = (vend), \ 781 - .idProduct = (prod) 764 + .match_flags = USB_DEVICE_ID_MATCH_DEVICE, \ 765 + .idVendor = (vend), \ 766 + .idProduct = (prod) 782 767 /** 783 768 * USB_DEVICE_VER - macro used to describe a specific usb device with a 784 769 * version range ··· 791 774 * This macro is used to create a struct usb_device_id that matches a 792 775 * specific device, with a version range. 793 776 */ 794 - #define USB_DEVICE_VER(vend,prod,lo,hi) \ 777 + #define USB_DEVICE_VER(vend, prod, lo, hi) \ 795 778 .match_flags = USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION, \ 796 - .idVendor = (vend), .idProduct = (prod), \ 797 - .bcdDevice_lo = (lo), .bcdDevice_hi = (hi) 779 + .idVendor = (vend), \ 780 + .idProduct = (prod), \ 781 + .bcdDevice_lo = (lo), \ 782 + .bcdDevice_hi = (hi) 798 783 799 784 /** 800 785 * USB_DEVICE_INTERFACE_PROTOCOL - macro used to describe a usb ··· 808 789 * This macro is used to create a struct usb_device_id that matches a 809 790 * specific interface protocol of devices. 810 791 */ 811 - #define USB_DEVICE_INTERFACE_PROTOCOL(vend,prod,pr) \ 812 - .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_PROTOCOL, \ 792 + #define USB_DEVICE_INTERFACE_PROTOCOL(vend, prod, pr) \ 793 + .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ 794 + USB_DEVICE_ID_MATCH_INT_PROTOCOL, \ 813 795 .idVendor = (vend), \ 814 796 .idProduct = (prod), \ 815 797 .bInterfaceProtocol = (pr) ··· 824 804 * This macro is used to create a struct usb_device_id that matches a 825 805 * specific class of devices. 826 806 */ 827 - #define USB_DEVICE_INFO(cl,sc,pr) \ 828 - .match_flags = USB_DEVICE_ID_MATCH_DEV_INFO, .bDeviceClass = (cl), \ 829 - .bDeviceSubClass = (sc), .bDeviceProtocol = (pr) 807 + #define USB_DEVICE_INFO(cl, sc, pr) \ 808 + .match_flags = USB_DEVICE_ID_MATCH_DEV_INFO, \ 809 + .bDeviceClass = (cl), \ 810 + .bDeviceSubClass = (sc), \ 811 + .bDeviceProtocol = (pr) 830 812 831 813 /** 832 - * USB_INTERFACE_INFO - macro used to describe a class of usb interfaces 814 + * USB_INTERFACE_INFO - macro used to describe a class of usb interfaces 833 815 * @cl: bInterfaceClass value 834 816 * @sc: bInterfaceSubClass value 835 817 * @pr: bInterfaceProtocol value ··· 839 817 * This macro is used to create a struct usb_device_id that matches a 840 818 * specific class of interfaces. 841 819 */ 842 - #define USB_INTERFACE_INFO(cl,sc,pr) \ 843 - .match_flags = USB_DEVICE_ID_MATCH_INT_INFO, .bInterfaceClass = (cl), \ 844 - .bInterfaceSubClass = (sc), .bInterfaceProtocol = (pr) 820 + #define USB_INTERFACE_INFO(cl, sc, pr) \ 821 + .match_flags = USB_DEVICE_ID_MATCH_INT_INFO, \ 822 + .bInterfaceClass = (cl), \ 823 + .bInterfaceSubClass = (sc), \ 824 + .bInterfaceProtocol = (pr) 845 825 846 826 /** 847 827 * USB_DEVICE_AND_INTERFACE_INFO - macro used to describe a specific usb device ··· 860 836 * This is especially useful when explicitly matching devices that have 861 837 * vendor specific bDeviceClass values, but standards-compliant interfaces. 862 838 */ 863 - #define USB_DEVICE_AND_INTERFACE_INFO(vend,prod,cl,sc,pr) \ 839 + #define USB_DEVICE_AND_INTERFACE_INFO(vend, prod, cl, sc, pr) \ 864 840 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO \ 865 841 | USB_DEVICE_ID_MATCH_DEVICE, \ 866 - .idVendor = (vend), .idProduct = (prod), \ 842 + .idVendor = (vend), \ 843 + .idProduct = (prod), \ 867 844 .bInterfaceClass = (cl), \ 868 - .bInterfaceSubClass = (sc), .bInterfaceProtocol = (pr) 845 + .bInterfaceSubClass = (sc), \ 846 + .bInterfaceProtocol = (pr) 869 847 870 848 /* ----------------------------------------------------------------------- */ 871 849 ··· 1145 1119 * transferred. It will normally be the same as requested, unless 1146 1120 * either an error was reported or a short read was performed. 1147 1121 * The URB_SHORT_NOT_OK transfer flag may be used to make such 1148 - * short reads be reported as errors. 1122 + * short reads be reported as errors. 1149 1123 * @setup_packet: Only used for control transfers, this points to eight bytes 1150 1124 * of setup data. Control transfers always start by sending this data 1151 1125 * to the device. Then transfer_buffer is read or written, if needed. ··· 1164 1138 * @complete: Completion handler. This URB is passed as the parameter to the 1165 1139 * completion function. The completion function may then do what 1166 1140 * it likes with the URB, including resubmitting or freeing it. 1167 - * @iso_frame_desc: Used to provide arrays of ISO transfer buffers and to 1141 + * @iso_frame_desc: Used to provide arrays of ISO transfer buffers and to 1168 1142 * collect the transfer status for each buffer. 1169 1143 * 1170 1144 * This structure identifies USB transfer requests. URBs must be allocated by ··· 1268 1242 * when the urb is owned by the hcd, that is, since the call to 1269 1243 * usb_submit_urb() till the entry into the completion routine. 1270 1244 */ 1271 - struct urb 1272 - { 1245 + struct urb { 1273 1246 /* private: usb core and host controller only fields in the urb */ 1274 1247 struct kref kref; /* reference count of the URB */ 1275 1248 void *hcpriv; /* private data for host controller */ ··· 1279 1254 /* public: documented fields in the urb that can be used by drivers */ 1280 1255 struct list_head urb_list; /* list head for use by the urb's 1281 1256 * current owner */ 1282 - struct list_head anchor_list; /* the URB may be anchored by the driver */ 1257 + struct list_head anchor_list; /* the URB may be anchored */ 1283 1258 struct usb_anchor *anchor; 1284 1259 struct usb_device *dev; /* (in) pointer to associated device */ 1285 - struct usb_host_endpoint *ep; /* (internal) pointer to endpoint struct */ 1260 + struct usb_host_endpoint *ep; /* (internal) pointer to endpoint */ 1286 1261 unsigned int pipe; /* (in) pipe information */ 1287 1262 int status; /* (return) non-ISO status */ 1288 1263 unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/ ··· 1319 1294 * Initializes a control urb with the proper information needed to submit 1320 1295 * it to a device. 1321 1296 */ 1322 - static inline void usb_fill_control_urb (struct urb *urb, 1323 - struct usb_device *dev, 1324 - unsigned int pipe, 1325 - unsigned char *setup_packet, 1326 - void *transfer_buffer, 1327 - int buffer_length, 1328 - usb_complete_t complete_fn, 1329 - void *context) 1297 + static inline void usb_fill_control_urb(struct urb *urb, 1298 + struct usb_device *dev, 1299 + unsigned int pipe, 1300 + unsigned char *setup_packet, 1301 + void *transfer_buffer, 1302 + int buffer_length, 1303 + usb_complete_t complete_fn, 1304 + void *context) 1330 1305 { 1331 1306 urb->dev = dev; 1332 1307 urb->pipe = pipe; ··· 1350 1325 * Initializes a bulk urb with the proper information needed to submit it 1351 1326 * to a device. 1352 1327 */ 1353 - static inline void usb_fill_bulk_urb (struct urb *urb, 1354 - struct usb_device *dev, 1355 - unsigned int pipe, 1356 - void *transfer_buffer, 1357 - int buffer_length, 1358 - usb_complete_t complete_fn, 1359 - void *context) 1328 + static inline void usb_fill_bulk_urb(struct urb *urb, 1329 + struct usb_device *dev, 1330 + unsigned int pipe, 1331 + void *transfer_buffer, 1332 + int buffer_length, 1333 + usb_complete_t complete_fn, 1334 + void *context) 1360 1335 { 1361 1336 urb->dev = dev; 1362 1337 urb->pipe = pipe; ··· 1384 1359 * the endpoint interval, and express polling intervals in microframes 1385 1360 * (eight per millisecond) rather than in frames (one per millisecond). 1386 1361 */ 1387 - static inline void usb_fill_int_urb (struct urb *urb, 1388 - struct usb_device *dev, 1389 - unsigned int pipe, 1390 - void *transfer_buffer, 1391 - int buffer_length, 1392 - usb_complete_t complete_fn, 1393 - void *context, 1394 - int interval) 1362 + static inline void usb_fill_int_urb(struct urb *urb, 1363 + struct usb_device *dev, 1364 + unsigned int pipe, 1365 + void *transfer_buffer, 1366 + int buffer_length, 1367 + usb_complete_t complete_fn, 1368 + void *context, 1369 + int interval) 1395 1370 { 1396 1371 urb->dev = dev; 1397 1372 urb->pipe = pipe; ··· 1444 1419 return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT; 1445 1420 } 1446 1421 1447 - void *usb_buffer_alloc (struct usb_device *dev, size_t size, 1422 + void *usb_buffer_alloc(struct usb_device *dev, size_t size, 1448 1423 gfp_t mem_flags, dma_addr_t *dma); 1449 - void usb_buffer_free (struct usb_device *dev, size_t size, 1424 + void usb_buffer_free(struct usb_device *dev, size_t size, 1450 1425 void *addr, dma_addr_t dma); 1451 1426 1452 1427 #if 0 1453 - struct urb *usb_buffer_map (struct urb *urb); 1454 - void usb_buffer_dmasync (struct urb *urb); 1455 - void usb_buffer_unmap (struct urb *urb); 1428 + struct urb *usb_buffer_map(struct urb *urb); 1429 + void usb_buffer_dmasync(struct urb *urb); 1430 + void usb_buffer_unmap(struct urb *urb); 1456 1431 #endif 1457 1432 1458 1433 struct scatterlist; ··· 1524 1499 int status; 1525 1500 size_t bytes; 1526 1501 1527 - /* 1502 + /* 1528 1503 * members below are private: to usbcore, 1529 1504 * and are not provided for driver access! 1530 1505 */ ··· 1542 1517 struct completion complete; 1543 1518 }; 1544 1519 1545 - int usb_sg_init ( 1520 + int usb_sg_init( 1546 1521 struct usb_sg_request *io, 1547 1522 struct usb_device *dev, 1548 - unsigned pipe, 1523 + unsigned pipe, 1549 1524 unsigned period, 1550 1525 struct scatterlist *sg, 1551 1526 int nents, 1552 1527 size_t length, 1553 1528 gfp_t mem_flags 1554 1529 ); 1555 - void usb_sg_cancel (struct usb_sg_request *io); 1556 - void usb_sg_wait (struct usb_sg_request *io); 1530 + void usb_sg_cancel(struct usb_sg_request *io); 1531 + void usb_sg_wait(struct usb_sg_request *io); 1557 1532 1558 1533 1559 1534 /* ----------------------------------------------------------------------- */ ··· 1610 1585 1611 1586 /* Create various pipes... */ 1612 1587 #define usb_sndctrlpipe(dev,endpoint) \ 1613 - ((PIPE_CONTROL << 30) | __create_pipe(dev,endpoint)) 1588 + ((PIPE_CONTROL << 30) | __create_pipe(dev, endpoint)) 1614 1589 #define usb_rcvctrlpipe(dev,endpoint) \ 1615 - ((PIPE_CONTROL << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1590 + ((PIPE_CONTROL << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) 1616 1591 #define usb_sndisocpipe(dev,endpoint) \ 1617 - ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev,endpoint)) 1592 + ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev, endpoint)) 1618 1593 #define usb_rcvisocpipe(dev,endpoint) \ 1619 - ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1594 + ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) 1620 1595 #define usb_sndbulkpipe(dev,endpoint) \ 1621 - ((PIPE_BULK << 30) | __create_pipe(dev,endpoint)) 1596 + ((PIPE_BULK << 30) | __create_pipe(dev, endpoint)) 1622 1597 #define usb_rcvbulkpipe(dev,endpoint) \ 1623 - ((PIPE_BULK << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1598 + ((PIPE_BULK << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) 1624 1599 #define usb_sndintpipe(dev,endpoint) \ 1625 - ((PIPE_INTERRUPT << 30) | __create_pipe(dev,endpoint)) 1600 + ((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint)) 1626 1601 #define usb_rcvintpipe(dev,endpoint) \ 1627 - ((PIPE_INTERRUPT << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1602 + ((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) 1628 1603 1629 1604 /*-------------------------------------------------------------------------*/ 1630 1605
+6 -5
include/linux/usb/Kbuild
··· 1 - unifdef-y += audio.h 2 - unifdef-y += cdc.h 3 - unifdef-y += ch9.h 4 - unifdef-y += gadgetfs.h 5 - unifdef-y += midi.h 1 + header-y += audio.h 2 + header-y += cdc.h 3 + header-y += ch9.h 4 + header-y += gadgetfs.h 5 + header-y += midi.h 6 + unifdef-y += g_printer.h 6 7
+7 -7
include/linux/usb/audio.h
··· 27 27 28 28 /* 4.3.2 Class-Specific AC Interface Descriptor */ 29 29 struct usb_ac_header_descriptor { 30 - __u8 bLength; // 8+n 31 - __u8 bDescriptorType; // USB_DT_CS_INTERFACE 32 - __u8 bDescriptorSubtype; // USB_MS_HEADER 33 - __le16 bcdADC; // 0x0100 34 - __le16 wTotalLength; // includes Unit and Terminal desc. 35 - __u8 bInCollection; // n 36 - __u8 baInterfaceNr[]; // [n] 30 + __u8 bLength; /* 8+n */ 31 + __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ 32 + __u8 bDescriptorSubtype; /* USB_MS_HEADER */ 33 + __le16 bcdADC; /* 0x0100 */ 34 + __le16 wTotalLength; /* includes Unit and Terminal desc. */ 35 + __u8 bInCollection; /* n */ 36 + __u8 baInterfaceNr[]; /* [n] */ 37 37 } __attribute__ ((packed)); 38 38 39 39 #define USB_DT_AC_HEADER_SIZE(n) (8+(n))
+8 -8
include/linux/usb/cdc.h
··· 29 29 * Class-Specific descriptors ... there are a couple dozen of them 30 30 */ 31 31 32 - #define USB_CDC_HEADER_TYPE 0x00 /* header_desc */ 33 - #define USB_CDC_CALL_MANAGEMENT_TYPE 0x01 /* call_mgmt_descriptor */ 34 - #define USB_CDC_ACM_TYPE 0x02 /* acm_descriptor */ 35 - #define USB_CDC_UNION_TYPE 0x06 /* union_desc */ 32 + #define USB_CDC_HEADER_TYPE 0x00 /* header_desc */ 33 + #define USB_CDC_CALL_MANAGEMENT_TYPE 0x01 /* call_mgmt_descriptor */ 34 + #define USB_CDC_ACM_TYPE 0x02 /* acm_descriptor */ 35 + #define USB_CDC_UNION_TYPE 0x06 /* union_desc */ 36 36 #define USB_CDC_COUNTRY_TYPE 0x07 37 - #define USB_CDC_NETWORK_TERMINAL_TYPE 0x0a /* network_terminal_desc */ 38 - #define USB_CDC_ETHERNET_TYPE 0x0f /* ether_desc */ 37 + #define USB_CDC_NETWORK_TERMINAL_TYPE 0x0a /* network_terminal_desc */ 38 + #define USB_CDC_ETHERNET_TYPE 0x0f /* ether_desc */ 39 39 #define USB_CDC_WHCM_TYPE 0x11 40 - #define USB_CDC_MDLM_TYPE 0x12 /* mdlm_desc */ 41 - #define USB_CDC_MDLM_DETAIL_TYPE 0x13 /* mdlm_detail_desc */ 40 + #define USB_CDC_MDLM_TYPE 0x12 /* mdlm_desc */ 41 + #define USB_CDC_MDLM_DETAIL_TYPE 0x13 /* mdlm_detail_desc */ 42 42 #define USB_CDC_DMM_TYPE 0x14 43 43 #define USB_CDC_OBEX_TYPE 0x15 44 44
+31
include/linux/usb/g_printer.h
··· 1 + /* 2 + * g_printer.h -- Header file for USB Printer gadget driver 3 + * 4 + * Copyright (C) 2007 Craig W. Nadler 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License as published by 8 + * the Free Software Foundation; either version 2 of the License, or 9 + * (at your option) any later version. 10 + * 11 + * This program is distributed in the hope that it will be useful, 12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 + * GNU General Public License for more details. 15 + * 16 + * You should have received a copy of the GNU General Public License 17 + * along with this program; if not, write to the Free Software 18 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 + */ 20 + 21 + 22 + #define PRINTER_NOT_ERROR 0x08 23 + #define PRINTER_SELECTED 0x10 24 + #define PRINTER_PAPER_EMPTY 0x20 25 + 26 + /* The 'g' code is also used by gadgetfs ioctl requests. 27 + * Don't add any colliding codes to either driver, and keep 28 + * them in unique ranges (size 0x20 for now). 29 + */ 30 + #define GADGET_GET_PRINTER_STATUS _IOR('g', 0x21, unsigned char) 31 + #define GADGET_SET_PRINTER_STATUS _IOWR('g', 0x22, unsigned char)
+55 -68
include/linux/usb/gadget.h
··· 70 70 * 71 71 * Bulk endpoints can use any size buffers, and can also be used for interrupt 72 72 * transfers. interrupt-only endpoints can be much less functional. 73 + * 74 + * NOTE: this is analagous to 'struct urb' on the host side, except that 75 + * it's thinner and promotes more pre-allocation. 73 76 */ 74 - // NOTE this is analagous to 'struct urb' on the host side, 75 - // except that it's thinner and promotes more pre-allocation. 76 77 77 78 struct usb_request { 78 79 void *buf; ··· 169 168 * 170 169 * returns zero, or a negative error code. 171 170 */ 172 - static inline int 173 - usb_ep_enable (struct usb_ep *ep, const struct usb_endpoint_descriptor *desc) 171 + static inline int usb_ep_enable(struct usb_ep *ep, 172 + const struct usb_endpoint_descriptor *desc) 174 173 { 175 - return ep->ops->enable (ep, desc); 174 + return ep->ops->enable(ep, desc); 176 175 } 177 176 178 177 /** ··· 187 186 * 188 187 * returns zero, or a negative error code. 189 188 */ 190 - static inline int 191 - usb_ep_disable (struct usb_ep *ep) 189 + static inline int usb_ep_disable(struct usb_ep *ep) 192 190 { 193 - return ep->ops->disable (ep); 191 + return ep->ops->disable(ep); 194 192 } 195 193 196 194 /** ··· 206 206 * 207 207 * Returns the request, or null if one could not be allocated. 208 208 */ 209 - static inline struct usb_request * 210 - usb_ep_alloc_request (struct usb_ep *ep, gfp_t gfp_flags) 209 + static inline struct usb_request *usb_ep_alloc_request(struct usb_ep *ep, 210 + gfp_t gfp_flags) 211 211 { 212 - return ep->ops->alloc_request (ep, gfp_flags); 212 + return ep->ops->alloc_request(ep, gfp_flags); 213 213 } 214 214 215 215 /** ··· 221 221 * Caller guarantees the request is not queued, and that it will 222 222 * no longer be requeued (or otherwise used). 223 223 */ 224 - static inline void 225 - usb_ep_free_request (struct usb_ep *ep, struct usb_request *req) 224 + static inline void usb_ep_free_request(struct usb_ep *ep, 225 + struct usb_request *req) 226 226 { 227 - ep->ops->free_request (ep, req); 227 + ep->ops->free_request(ep, req); 228 228 } 229 229 230 230 /** ··· 281 281 * report errors; errors will also be 282 282 * reported when the usb peripheral is disconnected. 283 283 */ 284 - static inline int 285 - usb_ep_queue (struct usb_ep *ep, struct usb_request *req, gfp_t gfp_flags) 284 + static inline int usb_ep_queue(struct usb_ep *ep, 285 + struct usb_request *req, gfp_t gfp_flags) 286 286 { 287 - return ep->ops->queue (ep, req, gfp_flags); 287 + return ep->ops->queue(ep, req, gfp_flags); 288 288 } 289 289 290 290 /** ··· 301 301 * restrictions prevent drivers from supporting configuration changes, 302 302 * even to configuration zero (a "chapter 9" requirement). 303 303 */ 304 - static inline int usb_ep_dequeue (struct usb_ep *ep, struct usb_request *req) 304 + static inline int usb_ep_dequeue(struct usb_ep *ep, struct usb_request *req) 305 305 { 306 - return ep->ops->dequeue (ep, req); 306 + return ep->ops->dequeue(ep, req); 307 307 } 308 308 309 309 /** ··· 327 327 * transfer requests are still queued, or if the controller hardware 328 328 * (usually a FIFO) still holds bytes that the host hasn't collected. 329 329 */ 330 - static inline int 331 - usb_ep_set_halt (struct usb_ep *ep) 330 + static inline int usb_ep_set_halt(struct usb_ep *ep) 332 331 { 333 - return ep->ops->set_halt (ep, 1); 332 + return ep->ops->set_halt(ep, 1); 334 333 } 335 334 336 335 /** ··· 345 346 * Note that some hardware can't support this request (like pxa2xx_udc), 346 347 * and accordingly can't correctly implement interface altsettings. 347 348 */ 348 - static inline int 349 - usb_ep_clear_halt (struct usb_ep *ep) 349 + static inline int usb_ep_clear_halt(struct usb_ep *ep) 350 350 { 351 - return ep->ops->set_halt (ep, 0); 351 + return ep->ops->set_halt(ep, 0); 352 352 } 353 353 354 354 /** ··· 365 367 * errno if the endpoint doesn't use a FIFO or doesn't support such 366 368 * precise handling. 367 369 */ 368 - static inline int 369 - usb_ep_fifo_status (struct usb_ep *ep) 370 + static inline int usb_ep_fifo_status(struct usb_ep *ep) 370 371 { 371 372 if (ep->ops->fifo_status) 372 - return ep->ops->fifo_status (ep); 373 + return ep->ops->fifo_status(ep); 373 374 else 374 375 return -EOPNOTSUPP; 375 376 } ··· 382 385 * must never be used except when endpoint is not being used for any 383 386 * protocol translation. 384 387 */ 385 - static inline void 386 - usb_ep_fifo_flush (struct usb_ep *ep) 388 + static inline void usb_ep_fifo_flush(struct usb_ep *ep) 387 389 { 388 390 if (ep->ops->fifo_flush) 389 - ep->ops->fifo_flush (ep); 391 + ep->ops->fifo_flush(ep); 390 392 } 391 393 392 394 ··· 465 469 struct device dev; 466 470 }; 467 471 468 - static inline void set_gadget_data (struct usb_gadget *gadget, void *data) 469 - { dev_set_drvdata (&gadget->dev, data); } 470 - static inline void *get_gadget_data (struct usb_gadget *gadget) 471 - { return dev_get_drvdata (&gadget->dev); } 472 + static inline void set_gadget_data(struct usb_gadget *gadget, void *data) 473 + { dev_set_drvdata(&gadget->dev, data); } 474 + static inline void *get_gadget_data(struct usb_gadget *gadget) 475 + { return dev_get_drvdata(&gadget->dev); } 472 476 473 477 /* iterates the non-control endpoints; 'tmp' is a struct usb_ep pointer */ 474 478 #define gadget_for_each_ep(tmp,gadget) \ ··· 507 511 #endif 508 512 } 509 513 510 - 511 514 /** 512 515 * usb_gadget_frame_number - returns the current frame number 513 516 * @gadget: controller that reports the frame number ··· 514 519 * Returns the usb frame number, normally eleven bits from a SOF packet, 515 520 * or negative errno if this device doesn't support this capability. 516 521 */ 517 - static inline int usb_gadget_frame_number (struct usb_gadget *gadget) 522 + static inline int usb_gadget_frame_number(struct usb_gadget *gadget) 518 523 { 519 - return gadget->ops->get_frame (gadget); 524 + return gadget->ops->get_frame(gadget); 520 525 } 521 526 522 527 /** ··· 532 537 * even if OTG isn't otherwise in use. OTG devices may also start 533 538 * remote wakeup even when hosts don't explicitly enable it. 534 539 */ 535 - static inline int usb_gadget_wakeup (struct usb_gadget *gadget) 540 + static inline int usb_gadget_wakeup(struct usb_gadget *gadget) 536 541 { 537 542 if (!gadget->ops->wakeup) 538 543 return -EOPNOTSUPP; 539 - return gadget->ops->wakeup (gadget); 544 + return gadget->ops->wakeup(gadget); 540 545 } 541 546 542 547 /** ··· 548 553 * 549 554 * returns zero on success, else negative errno. 550 555 */ 551 - static inline int 552 - usb_gadget_set_selfpowered (struct usb_gadget *gadget) 556 + static inline int usb_gadget_set_selfpowered(struct usb_gadget *gadget) 553 557 { 554 558 if (!gadget->ops->set_selfpowered) 555 559 return -EOPNOTSUPP; 556 - return gadget->ops->set_selfpowered (gadget, 1); 560 + return gadget->ops->set_selfpowered(gadget, 1); 557 561 } 558 562 559 563 /** ··· 565 571 * 566 572 * returns zero on success, else negative errno. 567 573 */ 568 - static inline int 569 - usb_gadget_clear_selfpowered (struct usb_gadget *gadget) 574 + static inline int usb_gadget_clear_selfpowered(struct usb_gadget *gadget) 570 575 { 571 576 if (!gadget->ops->set_selfpowered) 572 577 return -EOPNOTSUPP; 573 - return gadget->ops->set_selfpowered (gadget, 0); 578 + return gadget->ops->set_selfpowered(gadget, 0); 574 579 } 575 580 576 581 /** ··· 584 591 * 585 592 * Returns zero on success, else negative errno. 586 593 */ 587 - static inline int 588 - usb_gadget_vbus_connect(struct usb_gadget *gadget) 594 + static inline int usb_gadget_vbus_connect(struct usb_gadget *gadget) 589 595 { 590 596 if (!gadget->ops->vbus_session) 591 597 return -EOPNOTSUPP; 592 - return gadget->ops->vbus_session (gadget, 1); 598 + return gadget->ops->vbus_session(gadget, 1); 593 599 } 594 600 595 601 /** ··· 603 611 * 604 612 * Returns zero on success, else negative errno. 605 613 */ 606 - static inline int 607 - usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA) 614 + static inline int usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA) 608 615 { 609 616 if (!gadget->ops->vbus_draw) 610 617 return -EOPNOTSUPP; 611 - return gadget->ops->vbus_draw (gadget, mA); 618 + return gadget->ops->vbus_draw(gadget, mA); 612 619 } 613 620 614 621 /** ··· 620 629 * 621 630 * Returns zero on success, else negative errno. 622 631 */ 623 - static inline int 624 - usb_gadget_vbus_disconnect(struct usb_gadget *gadget) 632 + static inline int usb_gadget_vbus_disconnect(struct usb_gadget *gadget) 625 633 { 626 634 if (!gadget->ops->vbus_session) 627 635 return -EOPNOTSUPP; 628 - return gadget->ops->vbus_session (gadget, 0); 636 + return gadget->ops->vbus_session(gadget, 0); 629 637 } 630 638 631 639 /** ··· 638 648 * 639 649 * Returns zero on success, else negative errno. 640 650 */ 641 - static inline int 642 - usb_gadget_connect (struct usb_gadget *gadget) 651 + static inline int usb_gadget_connect(struct usb_gadget *gadget) 643 652 { 644 653 if (!gadget->ops->pullup) 645 654 return -EOPNOTSUPP; 646 - return gadget->ops->pullup (gadget, 1); 655 + return gadget->ops->pullup(gadget, 1); 647 656 } 648 657 649 658 /** ··· 660 671 * 661 672 * Returns zero on success, else negative errno. 662 673 */ 663 - static inline int 664 - usb_gadget_disconnect (struct usb_gadget *gadget) 674 + static inline int usb_gadget_disconnect(struct usb_gadget *gadget) 665 675 { 666 676 if (!gadget->ops->pullup) 667 677 return -EOPNOTSUPP; 668 - return gadget->ops->pullup (gadget, 0); 678 + return gadget->ops->pullup(gadget, 0); 669 679 } 670 - 671 680 672 681 673 682 /*-------------------------------------------------------------------------*/ ··· 751 764 void (*suspend)(struct usb_gadget *); 752 765 void (*resume)(struct usb_gadget *); 753 766 754 - // FIXME support safe rmmod 767 + /* FIXME support safe rmmod */ 755 768 struct device_driver driver; 756 769 }; 757 770 ··· 777 790 * the bind() functions will be in init sections. 778 791 * This function must be called in a context that can sleep. 779 792 */ 780 - int usb_gadget_register_driver (struct usb_gadget_driver *driver); 793 + int usb_gadget_register_driver(struct usb_gadget_driver *driver); 781 794 782 795 /** 783 796 * usb_gadget_unregister_driver - unregister a gadget driver ··· 792 805 * will in in exit sections, so may not be linked in some kernels. 793 806 * This function must be called in a context that can sleep. 794 807 */ 795 - int usb_gadget_unregister_driver (struct usb_gadget_driver *driver); 808 + int usb_gadget_unregister_driver(struct usb_gadget_driver *driver); 796 809 797 810 /*-------------------------------------------------------------------------*/ 798 811 ··· 825 838 }; 826 839 827 840 /* put descriptor for string with that id into buf (buflen >= 256) */ 828 - int usb_gadget_get_string (struct usb_gadget_strings *table, int id, u8 *buf); 841 + int usb_gadget_get_string(struct usb_gadget_strings *table, int id, u8 *buf); 829 842 830 843 /*-------------------------------------------------------------------------*/ 831 844 ··· 843 856 844 857 /* utility wrapping a simple endpoint selection policy */ 845 858 846 - extern struct usb_ep *usb_ep_autoconfig (struct usb_gadget *, 859 + extern struct usb_ep *usb_ep_autoconfig(struct usb_gadget *, 847 860 struct usb_endpoint_descriptor *) __devinit; 848 861 849 - extern void usb_ep_autoconfig_reset (struct usb_gadget *) __devinit; 862 + extern void usb_ep_autoconfig_reset(struct usb_gadget *) __devinit; 850 863 851 864 #endif /* __KERNEL__ */ 852 865
+17 -10
include/linux/usb/gadgetfs.h
··· 36 36 GADGETFS_DISCONNECT, 37 37 GADGETFS_SETUP, 38 38 GADGETFS_SUSPEND, 39 - // and likely more ! 39 + /* and likely more ! */ 40 40 }; 41 41 42 42 /* NOTE: this structure must stay the same size and layout on ··· 44 44 */ 45 45 struct usb_gadgetfs_event { 46 46 union { 47 - // NOP, DISCONNECT, SUSPEND: nothing 48 - // ... some hardware can't report disconnection 47 + /* NOP, DISCONNECT, SUSPEND: nothing 48 + * ... some hardware can't report disconnection 49 + */ 49 50 50 - // CONNECT: just the speed 51 + /* CONNECT: just the speed */ 51 52 enum usb_device_speed speed; 52 53 53 - // SETUP: packet; DATA phase i/o precedes next event 54 - // (setup.bmRequestType & USB_DIR_IN) flags direction 55 - // ... includes SET_CONFIGURATION, SET_INTERFACE 54 + /* SETUP: packet; DATA phase i/o precedes next event 55 + *(setup.bmRequestType & USB_DIR_IN) flags direction 56 + * ... includes SET_CONFIGURATION, SET_INTERFACE 57 + */ 56 58 struct usb_ctrlrequest setup; 57 59 } u; 58 60 enum usb_gadgetfs_event_type type; 59 61 }; 60 62 63 + 64 + /* The 'g' code is also used by printer gadget ioctl requests. 65 + * Don't add any colliding codes to either driver, and keep 66 + * them in unique ranges (size 0x20 for now). 67 + */ 61 68 62 69 /* endpoint ioctls */ 63 70 ··· 75 68 * THIS returns how many bytes are "unclaimed" in the endpoint fifo 76 69 * (needed for precise fault handling, when the hardware allows it) 77 70 */ 78 - #define GADGETFS_FIFO_STATUS _IO('g',1) 71 + #define GADGETFS_FIFO_STATUS _IO('g', 1) 79 72 80 73 /* discards any unclaimed data in the fifo. */ 81 - #define GADGETFS_FIFO_FLUSH _IO('g',2) 74 + #define GADGETFS_FIFO_FLUSH _IO('g', 2) 82 75 83 76 /* resets endpoint halt+toggle; used to implement set_interface. 84 77 * some hardware (like pxa2xx) can't support this. 85 78 */ 86 - #define GADGETFS_CLEAR_HALT _IO('g',3) 79 + #define GADGETFS_CLEAR_HALT _IO('g', 3) 87 80 88 81 #endif /* __LINUX_USB_GADGETFS_H */
+17 -8
include/linux/usb/iowarrior.h
··· 14 14 this information. 15 15 */ 16 16 struct iowarrior_info { 17 - __u32 vendor; /* vendor id : supposed to be USB_VENDOR_ID_CODEMERCS in all cases */ 18 - __u32 product; /* product id : depends on type of chip (USB_DEVICE_ID_CODEMERCS_XXXXX) */ 19 - __u8 serial[9]; /* the serial number of our chip (if a serial-number is not available this is empty string) */ 20 - __u32 revision; /* revision number of the chip */ 21 - __u32 speed; /* USB-speed of the device (0=UNKNOWN, 1=LOW, 2=FULL 3=HIGH) */ 22 - __u32 power; /* power consumption of the device in mA */ 23 - __u32 if_num; /* the number of the endpoint */ 24 - __u32 report_size; /* size of the data-packets on this interface */ 17 + /* vendor id : supposed to be USB_VENDOR_ID_CODEMERCS in all cases */ 18 + __u32 vendor; 19 + /* product id : depends on type of chip (USB_DEVICE_ID_CODEMERCS_X) */ 20 + __u32 product; 21 + /* the serial number of our chip (if a serial-number is not available 22 + * this is empty string) */ 23 + __u8 serial[9]; 24 + /* revision number of the chip */ 25 + __u32 revision; 26 + /* USB-speed of the device (0=UNKNOWN, 1=LOW, 2=FULL 3=HIGH) */ 27 + __u32 speed; 28 + /* power consumption of the device in mA */ 29 + __u32 power; 30 + /* the number of the endpoint */ 31 + __u32 if_num; 32 + /* size of the data-packets on this interface */ 33 + __u32 report_size; 25 34 }; 26 35 27 36 /*
+1 -1
include/linux/usb/isp116x.h
··· 25 25 300ns delay between access to ADDR_REG and DATA_REG 26 26 OE, WE MUST NOT be changed during these intervals 27 27 */ 28 - void (*delay) (struct device * dev, int delay); 28 + void (*delay) (struct device *dev, int delay); 29 29 };
+13 -13
include/linux/usb/midi.h
··· 47 47 /* 6.1.2.2 MIDI IN Jack Descriptor */ 48 48 struct usb_midi_in_jack_descriptor { 49 49 __u8 bLength; 50 - __u8 bDescriptorType; // USB_DT_CS_INTERFACE 51 - __u8 bDescriptorSubtype; // USB_MS_MIDI_IN_JACK 52 - __u8 bJackType; // USB_MS_EMBEDDED/EXTERNAL 50 + __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ 51 + __u8 bDescriptorSubtype; /* USB_MS_MIDI_IN_JACK */ 52 + __u8 bJackType; /* USB_MS_EMBEDDED/EXTERNAL */ 53 53 __u8 bJackID; 54 54 __u8 iJack; 55 55 } __attribute__ ((packed)); ··· 64 64 /* 6.1.2.3 MIDI OUT Jack Descriptor */ 65 65 struct usb_midi_out_jack_descriptor { 66 66 __u8 bLength; 67 - __u8 bDescriptorType; // USB_DT_CS_INTERFACE 68 - __u8 bDescriptorSubtype; // USB_MS_MIDI_OUT_JACK 69 - __u8 bJackType; // USB_MS_EMBEDDED/EXTERNAL 67 + __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ 68 + __u8 bDescriptorSubtype; /* USB_MS_MIDI_OUT_JACK */ 69 + __u8 bJackType; /* USB_MS_EMBEDDED/EXTERNAL */ 70 70 __u8 bJackID; 71 - __u8 bNrInputPins; // p 72 - struct usb_midi_source_pin pins[]; // [p] 71 + __u8 bNrInputPins; /* p */ 72 + struct usb_midi_source_pin pins[]; /* [p] */ 73 73 /*__u8 iJack; -- ommitted due to variable-sized pins[] */ 74 74 } __attribute__ ((packed)); 75 75 ··· 90 90 91 91 /* 6.2.2 Class-Specific MS Bulk Data Endpoint Descriptor */ 92 92 struct usb_ms_endpoint_descriptor { 93 - __u8 bLength; // 4+n 94 - __u8 bDescriptorType; // USB_DT_CS_ENDPOINT 95 - __u8 bDescriptorSubtype; // USB_MS_GENERAL 96 - __u8 bNumEmbMIDIJack; // n 97 - __u8 baAssocJackID[]; // [n] 93 + __u8 bLength; /* 4+n */ 94 + __u8 bDescriptorType; /* USB_DT_CS_ENDPOINT */ 95 + __u8 bDescriptorSubtype; /* USB_MS_GENERAL */ 96 + __u8 bNumEmbMIDIJack; /* n */ 97 + __u8 baAssocJackID[]; /* [n] */ 98 98 } __attribute__ ((packed)); 99 99 100 100 #define USB_DT_MS_ENDPOINT_SIZE(n) (4 + (n))
+16 -16
include/linux/usb/net2280.h
··· 37 37 38 38 /* main registers, BAR0 + 0x0000 */ 39 39 struct net2280_regs { 40 - // offset 0x0000 40 + /* offset 0x0000 */ 41 41 u32 devinit; 42 42 #define LOCAL_CLOCK_FREQUENCY 8 43 43 #define FORCE_PCI_RESET 7 ··· 61 61 #define EEPROM_WRITE_DATA 0 62 62 u32 eeclkfreq; 63 63 u32 _unused0; 64 - // offset 0x0010 64 + /* offset 0x0010 */ 65 65 66 66 u32 pciirqenb0; /* interrupt PCI master ... */ 67 67 #define SETUP_PACKET_INTERRUPT_ENABLE 7 ··· 131 131 #define RESUME_INTERRUPT_ENABLE 1 132 132 #define SOF_INTERRUPT_ENABLE 0 133 133 134 - // offset 0x0020 134 + /* offset 0x0020 */ 135 135 u32 _unused1; 136 136 u32 usbirqenb1; 137 137 #define USB_INTERRUPT_ENABLE 31 ··· 195 195 #define SUSPEND_REQUEST_CHANGE_INTERRUPT 2 196 196 #define RESUME_INTERRUPT 1 197 197 #define SOF_INTERRUPT 0 198 - // offset 0x0030 198 + /* offset 0x0030 */ 199 199 u32 idxaddr; 200 200 u32 idxdata; 201 201 u32 fifoctl; ··· 204 204 #define PCI_BASE2_SELECT 2 205 205 #define FIFO_CONFIGURATION_SELECT 0 206 206 u32 _unused2; 207 - // offset 0x0040 207 + /* offset 0x0040 */ 208 208 u32 memaddr; 209 209 #define START 28 210 210 #define DIRECTION 27 ··· 213 213 u32 memdata0; 214 214 u32 memdata1; 215 215 u32 _unused3; 216 - // offset 0x0050 216 + /* offset 0x0050 */ 217 217 u32 gpioctl; 218 218 #define GPIO3_LED_SELECT 12 219 219 #define GPIO3_INTERRUPT_ENABLE 11 ··· 237 237 238 238 /* usb control, BAR0 + 0x0080 */ 239 239 struct net2280_usb_regs { 240 - // offset 0x0080 240 + /* offset 0x0080 */ 241 241 u32 stdrsp; 242 242 #define STALL_UNSUPPORTED_REQUESTS 31 243 243 #define SET_TEST_MODE 16 ··· 275 275 #define PME_WAKEUP_ENABLE 2 276 276 #define DEVICE_REMOTE_WAKEUP_ENABLE 1 277 277 #define SELF_POWERED_STATUS 0 278 - // offset 0x0090 278 + /* offset 0x0090 */ 279 279 u32 usbstat; 280 280 #define HIGH_SPEED 7 281 281 #define FULL_SPEED 6 ··· 291 291 #define TERMINATION_SELECT 0 292 292 u32 setup0123; 293 293 u32 setup4567; 294 - // offset 0x0090 294 + /* offset 0x0090 */ 295 295 u32 _unused0; 296 296 u32 ouraddr; 297 297 #define FORCE_IMMEDIATE 7 ··· 301 301 302 302 /* pci control, BAR0 + 0x0100 */ 303 303 struct net2280_pci_regs { 304 - // offset 0x0100 304 + /* offset 0x0100 */ 305 305 u32 pcimstctl; 306 306 #define PCI_ARBITER_PARK_SELECT 13 307 307 #define PCI_MULTI LEVEL_ARBITER 12 ··· 331 331 * that can be loaded into some of these registers. 332 332 */ 333 333 struct net2280_dma_regs { /* [11.7] */ 334 - // offset 0x0180, 0x01a0, 0x01c0, 0x01e0, 334 + /* offset 0x0180, 0x01a0, 0x01c0, 0x01e0, */ 335 335 u32 dmactl; 336 336 #define DMA_SCATTER_GATHER_DONE_INTERRUPT_ENABLE 25 337 337 #define DMA_CLEAR_COUNT_ENABLE 21 ··· 355 355 #define DMA_ABORT 1 356 356 #define DMA_START 0 357 357 u32 _unused0 [2]; 358 - // offset 0x0190, 0x01b0, 0x01d0, 0x01f0, 358 + /* offset 0x0190, 0x01b0, 0x01d0, 0x01f0, */ 359 359 u32 dmacount; 360 360 #define VALID_BIT 31 361 361 #define DMA_DIRECTION 30 ··· 371 371 /* dedicated endpoint registers, BAR0 + 0x0200 */ 372 372 373 373 struct net2280_dep_regs { /* [11.8] */ 374 - // offset 0x0200, 0x0210, 0x220, 0x230, 0x240 374 + /* offset 0x0200, 0x0210, 0x220, 0x230, 0x240 */ 375 375 u32 dep_cfg; 376 - // offset 0x0204, 0x0214, 0x224, 0x234, 0x244 376 + /* offset 0x0204, 0x0214, 0x224, 0x234, 0x244 */ 377 377 u32 dep_rsp; 378 378 u32 _unused [2]; 379 379 } __attribute__ ((packed)); ··· 383 383 * ep0 reserved for control; E and F have only 64 bytes of fifo 384 384 */ 385 385 struct net2280_ep_regs { /* [11.9] */ 386 - // offset 0x0300, 0x0320, 0x0340, 0x0360, 0x0380, 0x03a0, 0x03c0 386 + /* offset 0x0300, 0x0320, 0x0340, 0x0360, 0x0380, 0x03a0, 0x03c0 */ 387 387 u32 ep_cfg; 388 388 #define ENDPOINT_BYTE_COUNT 16 389 389 #define ENDPOINT_ENABLE 10 ··· 435 435 #define DATA_PACKET_TRANSMITTED_INTERRUPT 2 436 436 #define DATA_OUT_PING_TOKEN_INTERRUPT 1 437 437 #define DATA_IN_TOKEN_INTERRUPT 0 438 - // offset 0x0310, 0x0330, 0x0350, 0x0370, 0x0390, 0x03b0, 0x03d0 438 + /* offset 0x0310, 0x0330, 0x0350, 0x0370, 0x0390, 0x03b0, 0x03d0 */ 439 439 u32 ep_avail; 440 440 u32 ep_data; 441 441 u32 _unused0 [2];
+1 -1
include/linux/usb/otg.h
··· 1 - // include/linux/usb/otg.h 1 + /* USB OTG (On The Go) defines */ 2 2 3 3 /* 4 4 * These APIs may be used between USB controllers. USB device drivers
+89 -69
include/linux/usb/serial.h
··· 20 20 #define SERIAL_TTY_MAJOR 188 /* Nice legal number now */ 21 21 #define SERIAL_TTY_MINORS 255 /* loads of devices :) */ 22 22 23 - #define MAX_NUM_PORTS 8 /* The maximum number of ports one device can grab at once */ 23 + /* The maximum number of ports one device can grab at once */ 24 + #define MAX_NUM_PORTS 8 24 25 25 26 /* parity check flag */ 26 27 #define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK)) ··· 62 61 * ports of a device. 63 62 */ 64 63 struct usb_serial_port { 65 - struct usb_serial * serial; 66 - struct tty_struct * tty; 64 + struct usb_serial *serial; 65 + struct tty_struct *tty; 67 66 spinlock_t lock; 68 67 struct mutex mutex; 69 68 unsigned char number; 70 69 71 - unsigned char * interrupt_in_buffer; 72 - struct urb * interrupt_in_urb; 70 + unsigned char *interrupt_in_buffer; 71 + struct urb *interrupt_in_urb; 73 72 __u8 interrupt_in_endpointAddress; 74 73 75 - unsigned char * interrupt_out_buffer; 74 + unsigned char *interrupt_out_buffer; 76 75 int interrupt_out_size; 77 - struct urb * interrupt_out_urb; 76 + struct urb *interrupt_out_urb; 78 77 __u8 interrupt_out_endpointAddress; 79 78 80 - unsigned char * bulk_in_buffer; 79 + unsigned char *bulk_in_buffer; 81 80 int bulk_in_size; 82 - struct urb * read_urb; 81 + struct urb *read_urb; 83 82 __u8 bulk_in_endpointAddress; 84 83 85 - unsigned char * bulk_out_buffer; 84 + unsigned char *bulk_out_buffer; 86 85 int bulk_out_size; 87 - struct urb * write_urb; 86 + struct urb *write_urb; 88 87 int write_urb_busy; 89 88 __u8 bulk_out_endpointAddress; 90 89 ··· 93 92 int open_count; 94 93 char throttled; 95 94 char throttle_req; 95 + char console; 96 96 struct device dev; 97 97 }; 98 98 #define to_usb_serial_port(d) container_of(d, struct usb_serial_port, dev) 99 99 100 100 /* get and set the port private data pointer helper functions */ 101 - static inline void *usb_get_serial_port_data (struct usb_serial_port *port) 101 + static inline void *usb_get_serial_port_data(struct usb_serial_port *port) 102 102 { 103 103 return dev_get_drvdata(&port->dev); 104 104 } 105 105 106 - static inline void usb_set_serial_port_data (struct usb_serial_port *port, void *data) 106 + static inline void usb_set_serial_port_data(struct usb_serial_port *port, 107 + void *data) 107 108 { 108 109 dev_set_drvdata(&port->dev, data); 109 110 } ··· 128 125 * usb_set_serial_data() to access this. 129 126 */ 130 127 struct usb_serial { 131 - struct usb_device * dev; 132 - struct usb_serial_driver * type; 133 - struct usb_interface * interface; 128 + struct usb_device *dev; 129 + struct usb_serial_driver *type; 130 + struct usb_interface *interface; 131 + unsigned char disconnected; 134 132 unsigned char minor; 135 133 unsigned char num_ports; 136 134 unsigned char num_port_pointers; ··· 139 135 char num_interrupt_out; 140 136 char num_bulk_in; 141 137 char num_bulk_out; 142 - struct usb_serial_port * port[MAX_NUM_PORTS]; 138 + struct usb_serial_port *port[MAX_NUM_PORTS]; 143 139 struct kref kref; 144 - void * private; 140 + struct mutex disc_mutex; 141 + void *private; 145 142 }; 146 143 #define to_usb_serial(d) container_of(d, struct usb_serial, kref) 147 144 148 145 #define NUM_DONT_CARE 99 149 146 150 147 /* get and set the serial private data pointer helper functions */ 151 - static inline void *usb_get_serial_data (struct usb_serial *serial) 148 + static inline void *usb_get_serial_data(struct usb_serial *serial) 152 149 { 153 150 return serial->private; 154 151 } 155 152 156 - static inline void usb_set_serial_data (struct usb_serial *serial, void *data) 153 + static inline void usb_set_serial_data(struct usb_serial *serial, void *data) 157 154 { 158 155 serial->private = data; 159 156 } 160 157 161 158 /** 162 159 * usb_serial_driver - describes a usb serial driver 163 - * @description: pointer to a string that describes this driver. This string used 164 - * in the syslog messages when a device is inserted or removed. 160 + * @description: pointer to a string that describes this driver. This string 161 + * used in the syslog messages when a device is inserted or removed. 165 162 * @id_table: pointer to a list of usb_device_id structures that define all 166 163 * of the devices this structure can support. 167 164 * @num_interrupt_in: If a device doesn't have this many interrupt-in ··· 223 218 struct usb_driver *usb_driver; 224 219 struct usb_dynids dynids; 225 220 226 - int (*probe) (struct usb_serial *serial, const struct usb_device_id *id); 227 - int (*attach) (struct usb_serial *serial); 221 + int (*probe)(struct usb_serial *serial, const struct usb_device_id *id); 222 + int (*attach)(struct usb_serial *serial); 228 223 int (*calc_num_ports) (struct usb_serial *serial); 229 224 230 - void (*shutdown) (struct usb_serial *serial); 225 + void (*shutdown)(struct usb_serial *serial); 231 226 232 - int (*port_probe) (struct usb_serial_port *port); 233 - int (*port_remove) (struct usb_serial_port *port); 227 + int (*port_probe)(struct usb_serial_port *port); 228 + int (*port_remove)(struct usb_serial_port *port); 234 229 235 - int (*suspend) (struct usb_serial *serial, pm_message_t message); 236 - int (*resume) (struct usb_serial *serial); 230 + int (*suspend)(struct usb_serial *serial, pm_message_t message); 231 + int (*resume)(struct usb_serial *serial); 237 232 238 233 /* serial function calls */ 239 - int (*open) (struct usb_serial_port *port, struct file * filp); 240 - void (*close) (struct usb_serial_port *port, struct file * filp); 241 - int (*write) (struct usb_serial_port *port, const unsigned char *buf, int count); 242 - int (*write_room) (struct usb_serial_port *port); 243 - int (*ioctl) (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg); 244 - void (*set_termios) (struct usb_serial_port *port, struct ktermios * old); 245 - void (*break_ctl) (struct usb_serial_port *port, int break_state); 246 - int (*chars_in_buffer) (struct usb_serial_port *port); 247 - void (*throttle) (struct usb_serial_port *port); 248 - void (*unthrottle) (struct usb_serial_port *port); 249 - int (*tiocmget) (struct usb_serial_port *port, struct file *file); 250 - int (*tiocmset) (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear); 234 + int (*open)(struct usb_serial_port *port, struct file *filp); 235 + void (*close)(struct usb_serial_port *port, struct file *filp); 236 + int (*write)(struct usb_serial_port *port, const unsigned char *buf, 237 + int count); 238 + int (*write_room)(struct usb_serial_port *port); 239 + int (*ioctl)(struct usb_serial_port *port, struct file *file, 240 + unsigned int cmd, unsigned long arg); 241 + void (*set_termios)(struct usb_serial_port *port, struct ktermios *old); 242 + void (*break_ctl)(struct usb_serial_port *port, int break_state); 243 + int (*chars_in_buffer)(struct usb_serial_port *port); 244 + void (*throttle)(struct usb_serial_port *port); 245 + void (*unthrottle)(struct usb_serial_port *port); 246 + int (*tiocmget)(struct usb_serial_port *port, struct file *file); 247 + int (*tiocmset)(struct usb_serial_port *port, struct file *file, 248 + unsigned int set, unsigned int clear); 251 249 252 250 void (*read_int_callback)(struct urb *urb); 253 251 void (*write_int_callback)(struct urb *urb); 254 252 void (*read_bulk_callback)(struct urb *urb); 255 253 void (*write_bulk_callback)(struct urb *urb); 256 254 }; 257 - #define to_usb_serial_driver(d) container_of(d, struct usb_serial_driver, driver) 255 + #define to_usb_serial_driver(d) \ 256 + container_of(d, struct usb_serial_driver, driver) 258 257 259 258 extern int usb_serial_register(struct usb_serial_driver *driver); 260 259 extern void usb_serial_deregister(struct usb_serial_driver *driver); 261 260 extern void usb_serial_port_softint(struct usb_serial_port *port); 262 261 263 - extern int usb_serial_probe(struct usb_interface *iface, const struct usb_device_id *id); 262 + extern int usb_serial_probe(struct usb_interface *iface, 263 + const struct usb_device_id *id); 264 264 extern void usb_serial_disconnect(struct usb_interface *iface); 265 265 266 266 extern int usb_serial_suspend(struct usb_interface *intf, pm_message_t message); 267 267 extern int usb_serial_resume(struct usb_interface *intf); 268 268 269 - extern int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *data, int length, __u8 bRequest); 270 - extern int ezusb_set_reset (struct usb_serial *serial, unsigned char reset_bit); 269 + extern int ezusb_writememory(struct usb_serial *serial, int address, 270 + unsigned char *data, int length, __u8 bRequest); 271 + extern int ezusb_set_reset(struct usb_serial *serial, unsigned char reset_bit); 271 272 272 273 /* USB Serial console functions */ 273 274 #ifdef CONFIG_USB_SERIAL_CONSOLE 274 - extern void usb_serial_console_init (int debug, int minor); 275 - extern void usb_serial_console_exit (void); 275 + extern void usb_serial_console_init(int debug, int minor); 276 + extern void usb_serial_console_exit(void); 276 277 extern void usb_serial_console_disconnect(struct usb_serial *serial); 277 278 #else 278 - static inline void usb_serial_console_init (int debug, int minor) { } 279 - static inline void usb_serial_console_exit (void) { } 279 + static inline void usb_serial_console_init(int debug, int minor) { } 280 + static inline void usb_serial_console_exit(void) { } 280 281 static inline void usb_serial_console_disconnect(struct usb_serial *serial) {} 281 282 #endif 282 283 283 284 /* Functions needed by other parts of the usbserial core */ 284 - extern struct usb_serial *usb_serial_get_by_index (unsigned int minor); 285 + extern struct usb_serial *usb_serial_get_by_index(unsigned int minor); 285 286 extern void usb_serial_put(struct usb_serial *serial); 286 - extern int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp); 287 - extern int usb_serial_generic_write (struct usb_serial_port *port, const unsigned char *buf, int count); 288 - extern void usb_serial_generic_close (struct usb_serial_port *port, struct file *filp); 289 - extern int usb_serial_generic_resume (struct usb_serial *serial); 290 - extern int usb_serial_generic_write_room (struct usb_serial_port *port); 291 - extern int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port); 292 - extern void usb_serial_generic_read_bulk_callback (struct urb *urb); 293 - extern void usb_serial_generic_write_bulk_callback (struct urb *urb); 294 - extern void usb_serial_generic_throttle (struct usb_serial_port *port); 295 - extern void usb_serial_generic_unthrottle (struct usb_serial_port *port); 296 - extern void usb_serial_generic_shutdown (struct usb_serial *serial); 297 - extern int usb_serial_generic_register (int debug); 298 - extern void usb_serial_generic_deregister (void); 287 + extern int usb_serial_generic_open(struct usb_serial_port *port, 288 + struct file *filp); 289 + extern int usb_serial_generic_write(struct usb_serial_port *port, 290 + const unsigned char *buf, int count); 291 + extern void usb_serial_generic_close(struct usb_serial_port *port, 292 + struct file *filp); 293 + extern int usb_serial_generic_resume(struct usb_serial *serial); 294 + extern int usb_serial_generic_write_room(struct usb_serial_port *port); 295 + extern int usb_serial_generic_chars_in_buffer(struct usb_serial_port *port); 296 + extern void usb_serial_generic_read_bulk_callback(struct urb *urb); 297 + extern void usb_serial_generic_write_bulk_callback(struct urb *urb); 298 + extern void usb_serial_generic_throttle(struct usb_serial_port *port); 299 + extern void usb_serial_generic_unthrottle(struct usb_serial_port *port); 300 + extern void usb_serial_generic_shutdown(struct usb_serial *serial); 301 + extern int usb_serial_generic_register(int debug); 302 + extern void usb_serial_generic_deregister(void); 299 303 300 - extern int usb_serial_bus_register (struct usb_serial_driver *device); 301 - extern void usb_serial_bus_deregister (struct usb_serial_driver *device); 304 + extern int usb_serial_bus_register(struct usb_serial_driver *device); 305 + extern void usb_serial_bus_deregister(struct usb_serial_driver *device); 302 306 303 307 extern struct usb_serial_driver usb_serial_generic_device; 304 308 extern struct bus_type usb_serial_bus_type; ··· 321 307 int i; 322 308 323 309 if (debug) { 324 - dev_printk(KERN_DEBUG, dev, "%s - length = %d, data = ", function, size); 310 + dev_printk(KERN_DEBUG, dev, "%s - length = %d, data = ", 311 + function, size); 325 312 for (i = 0; i < size; ++i) 326 - printk ("%.2x ", data[i]); 327 - printk ("\n"); 313 + printk("%.2x ", data[i]); 314 + printk("\n"); 328 315 } 329 316 } 330 317 331 318 /* Use our own dbg macro */ 332 319 #undef dbg 333 - #define dbg(format, arg...) do { if (debug) printk(KERN_DEBUG "%s: " format "\n" , __FILE__ , ## arg); } while (0) 320 + #define dbg(format, arg...) \ 321 + do { \ 322 + if (debug) \ 323 + printk(KERN_DEBUG "%s: " format "\n" , __FILE__ , \ 324 + ## arg); \ 325 + } while (0) 334 326 335 327 336 328
+3 -3
include/linux/usb/sl811.h
··· 19 19 /* pulse sl811 nRST (probably with a GPIO) */ 20 20 void (*reset)(struct device *dev); 21 21 22 - // some boards need something like these: 23 - // int (*check_overcurrent)(struct device *dev); 24 - // void (*clock_enable)(struct device *dev, int is_on); 22 + /* some boards need something like these: */ 23 + /* int (*check_overcurrent)(struct device *dev); */ 24 + /* void (*clock_enable)(struct device *dev, int is_on); */ 25 25 }; 26 26
+2 -3
include/linux/usb_usual.h
··· 80 80 #define US_SC_UFI 0x04 /* Floppy */ 81 81 #define US_SC_8070 0x05 /* Removable media */ 82 82 #define US_SC_SCSI 0x06 /* Transparent */ 83 - #define US_SC_ISD200 0x07 /* ISD200 ATA */ 84 - #define US_SC_MIN US_SC_RBC 85 - #define US_SC_MAX US_SC_ISD200 83 + #define US_SC_LOCKABLE 0x07 /* Password-protected */ 86 84 85 + #define US_SC_ISD200 0xf0 /* ISD200 ATA */ 87 86 #define US_SC_DEVICE 0xff /* Use device's value */ 88 87 89 88 /* Protocols */
+1 -1
include/linux/usbdevice_fs.h
··· 104 104 int error_count; 105 105 unsigned int signr; /* signal to be sent on completion, 106 106 or 0 if none should be sent. */ 107 - void *usercontext; 107 + void __user *usercontext; 108 108 struct usbdevfs_iso_packet_desc iso_frame_desc[0]; 109 109 }; 110 110
+1 -1
scripts/mod/file2alias.c
··· 155 155 * Some modules (visor) have empty slots as placeholder for 156 156 * run-time specification that results in catch-all alias 157 157 */ 158 - if (!(id->idVendor | id->bDeviceClass | id->bInterfaceClass)) 158 + if (!(id->idVendor | id->idProduct | id->bDeviceClass | id->bInterfaceClass)) 159 159 return; 160 160 161 161 /* Convert numeric bcdDevice range into fnmatch-able pattern(s) */