This story uses kernel code 2.6.22. In the Linux kernel code directory, all the Code related to the device driver is under the drivers/directory. Using the ls command in this directory, you can see many subdirectories:
Lfg1:/usr/src/linux-2.6.22/drivers # ls
Kconfig acpi atm block char cpufreq dma fc4 hid ide
Input leds md mfd mtd oprofile pci ps3 s390 serial spi
Usb zorro Makefile amba auxdisplay bluetooth clocksource crypto
Edac firewire hwmon ieee1394 isdn macintosh media misc net
Parisc pcmcia rapidio sbus sh tc video acorn ata
Base cdrom connector dio eisa firmware i2c infiniband
Kvm mca message mmc nubus parport pnp rtc scsi sn
Telephony w1
The usb directory contains the drivers of all USB devices, and the usb directory contains its own subdirectories. Go in and have a look,
Lfg1: // usr/src/linux-2.6.22/drivers # cd usb/
Lfg1:/usr/src/linux-2.6.22/drivers/usb # ls
Kconfig Makefile README atm class core gadget host image misc mon
Serial storage usb-skeleton.c
Note that each directory contains a Kconfig file and Makefile, which is very important. We will introduce it later.
Our story is based on the drivers/usb/storage directory. In fact, the code here clearly shows how the USB flash drive we frequently access is working and how it is driven. But the code in this directory does not live in a paradise. They are always closely related to the outside world. You can continue to see:
Lfg1:/usr/src/linux-2.6.22/drivers/usb # cd storage/
Lfg1:/usr/src/linux-2.6.22/drivers/usb/storage # ls
Kconfig alauda. h debug. c dpcm. h initializers. c isd200.h karma. c
Onetouch. c protocol. h sddr09.c sddr55.h transport. c usb. c
Makefile datafab. c debug. h freecom. c initializers. h jumpshot. c
Karma. h onetouch. h scsiglue. c sddr09.h shuttle_usbat.c transport. h
Usb. h alauda. c datafab. h dpcm. c freecom. h isd200.c jumpshot. h
Libusual. c protocol. c scsiglue. h sddr55.c shuttle_usbat.h
Unusual_devs.h
At first glance, I was shocked. I used the 'wc-l * 'command to count the number of rows! However, perhaps, life is always full of ups and downs.
After carefully reading Makefile and Kconfig, the mood is much better.
**************************************** ****
Original article from "I am USB for Linux"