Scsi - Index of
Scsi - Index of Scsi - Index of
月有关,友情,并非总与疯斗打闹有关.这几个函数应该说是给后面做铺垫,红花总要有绿叶配,没有这段代码 的铺垫,到了后面usb 设备恐怕也无法正常工作吧.不过,一个利好消息是,这几个函数我们只会遇见这一次, 它们在整个故事中就这么一次露脸的机会,像我们每个人的青春,只有一次,无法回头.和我们每个人的青春 一样,都是绝版的.所以,让我们享受这段平淡无奇的代码吧. get_device_info, 这个函数定义于drivers/usb/storage/usb.c 中: 466 /* Get the unusual_devs entries and the string descriptors */ 467 static void get_device_info(struct us_data *us, int id_index) 468 { 469 struct usb_device *dev = us->pusb_dev; 470 struct usb_interface_descriptor *idesc = 471 &us->pusb_intf->cur_altsetting->desc; 472 struct us_unusual_dev *unusual_dev = &us_unusual_dev_list[id_index]; 473 struct usb_device_id *id = &storage_usb_ids[id_index]; 474 475 /* Store the entries */ 476 us->unusual_dev = unusual_dev; 477 us->subclass = (unusual_dev->useProtocol == US_SC_DEVICE) ? 478 idesc->bInterfaceSubClass : 479 unusual_dev->useProtocol; 480 us->protocol = (unusual_dev->useTransport == US_PR_DEVICE) ? 481 idesc->bInterfaceProtocol : 482 unusual_dev->useTransport; 483 us->flags = unusual_dev->flags; 484 485 /* Log a message if a non-generic unusual_dev entry contains an 486 * unnecessary subclass or protocol override. This may stimulate 487 * reports from users that will help us remove unneeded entries 488 * from the unusual_devs.h table. 489 */ 490 if (id->idVendor || id->idProduct) { 491 static char *msgs[3] = { 492 "an unneeded SubClass entry", 493 "an unneeded Protocol entry", 494 "unneeded SubClass and Protocol entries"}; 38 495 struct usb_device_descriptor *ddesc = &dev->descriptor; 496 int msg = -1; 497 498 if (unusual_dev->useProtocol != US_SC_DEVICE && 499 us->subclass == idesc->bInterfaceSubClass) 500 msg += 1; 501 if (unusual_dev->useTransport != US_PR_DEVICE && 502 us->protocol == idesc->bInterfaceProtocol) 503 msg += 2;
504 if (msg >= 0 && !(unusual_dev->flags & US_FL_NEED_OVERRIDE)) 505 printk(KERN_NOTICE USB_STORAGE "This device " 506 "(%04x,%04x,%04x S %02x P %02x)" 507 " has %s in unusual_devs.h\n" 508 " Please send a copy of this message to " 509 "\n", 510 ddesc->idVendor, ddesc->idProduct, 511 ddesc->bcdDevice, 512 idesc->bInterfaceSubClass, 513 idesc->bInterfaceProtocol, 514 msgs[msg]); 515 } 516 517 /* Read the device's string descriptors */ 518 if (dev->descriptor.iManufacturer) 519 usb_string(dev, dev->descriptor.iManufacturer, 520 us->vendor, sizeof(us->vendor)); 521 if (dev->descriptor.iProduct) 522 usb_string(dev, dev->descriptor.iProduct, 523 us->product, sizeof(us->product)); 524 if (dev->descriptor.iSerialNumber) 525 usb_string(dev, dev->descriptor.iSerialNumber, 526 us->serial, sizeof(us->serial)); 527 528 /* Use the unusual_dev strings if the device didn't provide them */ 529 if (strlen(us->vendor) == 0) { 530 if (unusual_dev->vendorName) 531 strlcpy(us->vendor, unusual_dev->vendorName, 532 sizeof(us->vendor)); 533 else 534 strcpy(us->vendor, "Unknown"); 535 } 536 if (strlen(us->product) == 0) { 537 if (unusual_dev->productName) 538 strlcpy(us->product, unusual_dev->productName, 39 539 sizeof(us->product)); 540 else 541 strcpy(us->product, "Unknown"); 542 } 543 if (strlen(us->serial) == 0) 544 strcpy(us->serial, "None"); 545 546 US_DEBUGP("Vendor: %s, Product: %s\n", us->vendor, us->product);
- Page 1 and 2: 摘要 ............................
- Page 3 and 4: 迷雾重重的Bulk 传输(二)....
- Page 5 and 6: 引子 也许是在复旦养成了
- Page 7 and 8: usb.h datafab.h dpcm.h initializers
- Page 9 and 10: 的Linux 内核划分为许许多
- Page 11 and 12: 目录下执行make 了.Ok,make 之
- Page 13 and 14: 只 是一个usb 接口.这些口
- Page 15 and 16: 中也定义了这么一些数据
- Page 17 and 18: 511 * @driver: the driver model cor
- Page 19 and 20: 233 .owner = THIS_MODULE, 234 .name
- Page 21 and 22: 91 * construct these entries. Each
- Page 23 and 24: 324 struct usb_host_config *actconf
- Page 25 and 26: 22 88 * @class_dev: driver model's
- Page 27 and 28: 必须给各个地方取名,完了
- Page 29 and 30: 26 136 trans_cmnd transport; /* tra
- Page 31 and 32: 944 init_MUTEX_LOCKED(&(us->sema));
- Page 33 and 34: 147 #if !defined(CONFIG_BLK_DEV_UB)
- Page 35 and 36: 124 #define USB_DEVICE_ID_MATCH_DEV
- Page 37 and 38: intf 来代替. us 之所以重要,
- Page 39: 睡眠,那就得用GPF_ATOMIC,这
- Page 43 and 44: 179 } 180 181 static struct us_unus
- Page 45 and 46: 711 /* Submitted by Hartmut Wahl */
- Page 47 and 48: 3. useProtocol 为US_SC_DEVICE, use
- Page 49 and 50: Bus 004 Device 001: ID 0000:0000 Bu
- Page 51 and 52: 993 result = get_pipes(us); 994 if
- Page 53 and 54: 631 us->transport_reset = usb_stor_
- Page 55 and 56: 659 us->max_lun = 0; 660 break; 661
- Page 57 and 58: 740 /* Calculate and store the pipe
- Page 59 and 60: storage 会有两个bulk 端点,用
- Page 61 and 62: 比如说,复旦大学,有一个主
- Page 63 and 64: 1079 #define PIPE_ISOCHRONOUS 0 108
- Page 65 and 66: 782 us->unusual_dev->initFunction(u
- Page 67 and 68: 630 * each frame is in the fields o
- Page 69 and 70: 716 * Bulk URBs may 717 * use the U
- Page 71 and 72: 802 int number_of_packets; /* (in)
- Page 73 and 74: 先说互斥锁.它诞生于这样
- Page 75 and 76: 920 US_DEBUGP("GetMaxLUN command re
- Page 77 and 78: 148 /* set up data structures for t
- Page 79 and 80: 90 * @wValue: matches the USB wValu
- Page 81 and 82: 830 void *transfer_buffer, 831 int
- Page 83 and 84: 25 { 26 x->done = 0; 27 init_waitqu
- Page 85 and 86: 都会过期,我开始怀疑,在这
- Page 87 and 88: 是实际长度,要么就是不成
- Page 89 and 90: 87 258 行,usb_pipeendpoint,定义
504 if (msg >= 0 && !(unusual_dev->flags & US_FL_NEED_OVERRIDE))<br />
505 printk(KERN_NOTICE USB_STORAGE "This device "<br />
506 "(%04x,%04x,%04x S %02x P %02x)"<br />
507 " has %s in unusual_devs.h\n"<br />
508 " Please send a copy <strong>of</strong> this message to "<br />
509 "\n",<br />
510 ddesc->idVendor, ddesc->idProduct,<br />
511 ddesc->bcdDevice,<br />
512 idesc->bInterfaceSubClass,<br />
513 idesc->bInterfaceProtocol,<br />
514 msgs[msg]);<br />
515 }<br />
516<br />
517 /* Read the device's string descriptors */<br />
518 if (dev->descriptor.iManufacturer)<br />
519 usb_string(dev, dev->descriptor.iManufacturer,<br />
520 us->vendor, size<strong>of</strong>(us->vendor));<br />
521 if (dev->descriptor.iProduct)<br />
522 usb_string(dev, dev->descriptor.iProduct,<br />
523 us->product, size<strong>of</strong>(us->product));<br />
524 if (dev->descriptor.iSerialNumber)<br />
525 usb_string(dev, dev->descriptor.iSerialNumber,<br />
526 us->serial, size<strong>of</strong>(us->serial));<br />
527<br />
528 /* Use the unusual_dev strings if the device didn't provide them */<br />
529 if (strlen(us->vendor) == 0) {<br />
530 if (unusual_dev->vendorName)<br />
531 strlcpy(us->vendor, unusual_dev->vendorName,<br />
532 size<strong>of</strong>(us->vendor));<br />
533 else<br />
534 strcpy(us->vendor, "Unknown");<br />
535 }<br />
536 if (strlen(us->product) == 0) {<br />
537 if (unusual_dev->productName)<br />
538 strlcpy(us->product, unusual_dev->productName,<br />
39<br />
539 size<strong>of</strong>(us->product));<br />
540 else<br />
541 strcpy(us->product, "Unknown");<br />
542 }<br />
543 if (strlen(us->serial) == 0)<br />
544 strcpy(us->serial, "None");<br />
545<br />
546 US_DEBUGP("Vendor: %s, Product: %s\n", us->vendor, us->product);