Team LiB
Previous Section Next Section

Chapter 17. kobjects and sysfs

A significant new feature in the 2.6 Linux kernel is the addition of a unified device model. The device model provides a single mechanism for representing devices and describing their topology in the system. Such a system provides several benefits:

  • Minimization of code duplication

  • A mechanism for providing common facilities, such as reference counting

  • The capability to enumerate all the devices in the system, view their status, and see to what bus they attach

  • The capability to generate a complete and valid tree of the entire device structure of the system, including all buses and interconnections

  • The capability to link devices to their drivers and vice versa

  • The capability to categorize devices by their class, such as input device, without the need to understand the physical device topology

  • The ability to walk the tree of devices from the leaves up to the root, powering down devices in the correct order

The initial motivation for the device model was this final point. To implement intelligent power management in the kernel, you need to be able to build a tree representing the device topology in the system. When powering down devices on a tree that grows down, the kernel must power down the lower (leaf) nodes of the tree before the higher nodes. For example, the kernel needs to turn off a USB mouse before it turns off the USB controller, and the kernel must power down the USB controller before the PCI bus. To do this accurately and efficiently for the entire system, the kernel needs a tree of devices.

    Team LiB
    Previous Section Next Section