|
|
Subscribe / Log in / New account

A fresh look at the kernel's device model

A fresh look at the kernel's device model

Posted May 29, 2015 10:08 UTC (Fri) by vrfy (guest, #13362)
Parent article: A fresh look at the kernel's device model

The so called "driver model" seemed never really thought through; even that time it appeared more like an export of the implementations how specific things worked, than an attempt to consistently "model" something to export to internal and external users. It was and still is over-complicated, and some part never made much sense when expressed in the kernel or when it was to be consumed by userspace.

In the past, we have removed and unified 3 needlessly different types of device (struct class_device, struct sys_device) from the "driver model". We merged the separate "block" subsystem into a class. We merged the confusingly separated hierarchies of devices into one single tree (people started to express hierarchies of devices in /sys/class).

The simple idea is that the "devices" of the system show up in one single tree at /sys/devices. Devices of a common type have a "subsystem" symlink pointing back to the subsystem's directory. All devices of that subsystem are listed there.
- /sys/devices is the single unified hierarchy of all devices, used to express parent/child relationships
- /sys/{bus,class} is home of the subsystem, the grouping/listing of devices of this type, used to lookup devices by subsystem + name

So at least the "device" itself and /sys/devices is something that looks kind of reasonable to consume today.

That subsystems are still called class and bus makes not much sense and it should be replaced by /sys/subsystem, and compatibility provided by symlinks only. /sys/class is conceptually insufficient, it cannot safely expose subsystem knobs, because it is a single directory occupied by the list of devices of that subsystem. There is no place for safely exposing other information. /sys/bus in contrast is fine, it has a "devices" subdirectory.

The distinction of bus vs. class never made much sense. For that reason, udev internally merges the view of them and only exposes "subsystem", it refuses to distinguish "bus" and "class". Even 8 years old udev versions would already start using /sys/subsystem if it appeared today :)
http://cgit.freedesktop.org/systemd/systemd/commit/?id=5a...


to post comments


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds