I am USB in Linux, I am a USB flash drive (1) Xiaocheng story

Source: Internet
Author: User
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 # lsKconfi...

 

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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.