• Patrick Mochel's avatar
    Introduce struct device_class · 78fc20f7
    Patrick Mochel authored
    Device classes describe a type (or class) of device, like an input device
    or network device, etc. This changeset defines a struct device_class that 
    each subsystem is expected to implement and register with the core.
    
    struct device_driver gains a devclass pointer which points to the class it
    belongs to. When the driver is registered, it is added to the class's list
    of drivers. Whenever a device is bound to that driver, it is added to the
    class by calling the class's add_device callback. 
    
    struct device gains a class_num field which is the per-class enumerated value
    of the device. It is incremented each time a device is registered with the
    class.
    
    Each device class gets a driverfs directory in class/<class name> and two
    subdirectories: 'devices' and 'drivers'. For each device added to the class,
    a symlink is created in the devices/ directory that points to the device's
    directory in the physical hierarchy. The name of the symlink is the enumerated
    number the device got when it was registered with the class.
    
    For each driver that's added to the class, a symlink is created in the class's
    drivers/ directory that points to the driver's directory. The name of this 
    symlink is a concatenation of <bus name>:<driver name> (to prevent namespace
    conflicts of drivers with the same name on different buses).
     
    78fc20f7
device.c 5.4 KB