07.06.2013 Views

Scsi - Index of

Scsi - Index of

Scsi - Index of

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

782 us->unusual_dev->initFunction(us);<br />

783<br />

784 up(&us->dev_semaphore);<br />

785<br />

786 /*<br />

787 * Since this is a new device, we need to register a SCSI<br />

788 * host definition with the higher SCSI layers.<br />

789 */<br />

790 us->host = scsi_host_alloc(&usb_stor_host_template, size<strong>of</strong>(us));<br />

791 if (!us->host) {<br />

792 printk(KERN_WARNING USB_STORAGE<br />

793 "Unable to allocate the scsi host\n");<br />

794 return -EBUSY;<br />

795 }<br />

796<br />

797 /* Set the hostdata to prepare for scanning */<br />

798 us->host->hostdata[0] = (unsigned long) us;<br />

799<br />

800 /* Start up our control thread */<br />

801 p = kernel_thread(usb_stor_control_thread, us, CLONE_VM);<br />

802 if (p < 0) {<br />

803 printk(KERN_WARNING USB_STORAGE<br />

804 "Unable to start control thread\n");<br />

805 return p;<br />

806 }<br />

807 us->pid = p;<br />

63<br />

808<br />

809 /* Wait for the thread to start */<br />

810 wait_for_completion(&(us->notify));<br />

811<br />

812 return 0;<br />

813 }<br />

待到山花浪漫时,她在丛中笑.一个悟性高的人应该一眼就能从这个函数中找出那行在丛中笑的代码来,<br />

没错,她就是801 行,kernel_thread,这个函数造就了许多的经典的Linux 内核模块,正是因为她的存<br />

在,Linux 中某些设备驱动程序的编写变得非常简单.可以说,对某些设备驱动程序来说,kernel_thread<br />

几<br />

乎是整个driver 的灵魂,或者说是该Linux 内核模块的灵魂.不管她隐藏的多么深,她总像漆黑中的萤火虫,<br />

那样的鲜明,那样的出众.甚至不夸张的说,对于很多模块来说,只要找到kernel_thread 这一行,基本上你<br />

就<br />

知道这个模块是怎么工作的了.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!