I am USB in Linux, I am a U disk (7), and a group of people are lonely.

Source: Internet
Author: User

Linux
The three important concepts of the device model are bus, device, and driver.
Bus
,
Device
And
Driver
. In fact, the kernel also defines such data structures. They are
Struct
Bus_type
,
Struct Device
,
Struct device_driver
The three important data structures come from the same place
Include/Linux/device. h
.

We know that there are many types of bus, such
PCI
Bus,
SCSI
Bus,
USB
Bus, so we will see
Linux
Kernel code appears
Pci_bus_type
,
Scsi_bus_type
,
Usb_bus_type
, They are all
Struct bus_type
Type variable. While
Struct bus_type
Two important members in the structure are:
Struct kset drivers
And
Struct kset Devices
.
Kset
And the other
Kobject
Exactly
2.6
Basic elements of the device model in the kernel.

Here we only need to know,
Drivers
And
Devices
To make
Struct bus_type
Linked to two linked lists, one is
Devices
Chain table, one is
Drivers
. That is to say, if you know the data structure of a bus, you can find the device associated with the bus and the driver that supports such devices.

To achieve these goals, you must report or register a device to the bus every time it appears. Each time a driver appears, report it to the bus or register it. For example, system initialization
Hour
To scan which devices are connected and create
Struct Device
Every time there is a driver, you have to prepare
Struct device_driver
Structure variable. Add all these variables to the corresponding linked list,
Device
Insert
Devices
Linked List,
Driver
Insert
Drivers
Linked List.
In this way, each device and driver can be found through the bus.

However, if only the device has no corresponding driver in the computer, the device cannot work. In turn, if only the driver has no device, the driver will not play any role.
Device
Too many,
Driver
It's getting bigger. They are like two from the world,
Device
Warm up each other,
Driver
But one of them is the same. They are waiting for the other half of their own.

 

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.