Driving Me Nuts - Device Classes
With the i2c-dev driver and two i2c adapter drivers (the i2c-piix4 and i2c-isa drivers) loaded, the /sys/class/i2c-dev directory might look like the following:
$ tree /sys/class/i2c-dev/
/sys/class/i2c-dev/
|-- i2c-0
| |-- dev
| |-- device -> ../../../devices/pci0/00:07.3
| `-- driver -> ../../../bus/pci/drivers/piix4-smbus
`-- i2c-2
|-- dev
|-- device -> ../../../devices/legacy/i2c-2
`-- driver -> ../../../bus/i2c/drivers/i2c_adapter
The dev file in the /sys/class/i2c-dev/i2c-2/ directory would contain the following string:
$ cat /sys/class/i2c-dev/i2c-2/dev 5902
which corresponds to major number 86 and minor number 2, the character major and minor numbers for this specific device.
Also, the /sys/bus/i2c/ directory with a few i2c client drivers loaded looks like:
$ tree /sys/bus/i2c/
/sys/bus/i2c/
|-- devices
| |-- 0-0050 -> ../../../devices/pci0/00:07.3/i2c-0/0-0050
| |-- 0-0051 -> ../../../devices/pci0/00:07.3/i2c-0/0-0051
| |-- 0-0052 -> ../../../devices/pci0/00:07.3/i2c-0/0-0052
| |-- 0-0053 -> ../../../devices/pci0/00:07.3/i2c-0/0-0053
| `-- 2-0290 -> ../../../devices/legacy/i2c-2/2-0290
`-- drivers
|-- dev driver
|-- eeprom
| |-- 0-0050 -> ../../../../devices/pci0/00:07.3/i2c-0/0-0050
| |-- 0-0051 -> ../../../../devices/pci0/00:07.3/i2c-0/0-0051
| |-- 0-0052 -> ../../../../devices/pci0/00:07.3/i2c-0/0-0052
| `-- 0-0053 -> ../../../../devices/pci0/00:07.3/i2c-0/0-0053
|-- i2c_adapter
`-- w83781d
`-- 2-0290 -> ../../../../devices/legacy/i2c-2/2-0290
And, the actual /sys/devices/ directories for the i2c adapters look like:
$ tree /sys/devices/pci0/00:07.3 /sys/devices/pci0/00:07.3 |-- class |-- device |-- i2c-0 | |-- 0-0050 | | |-- eeprom_00 | | |-- name | | `-- power | |-- 0-0051 | | |-- eeprom_00 | | |-- name | | `-- power | |-- 0-0052 | | |-- eeprom_00 | | |-- name | | `-- power | |-- 0-0053 | | |-- eeprom_00 | | |-- name | | `-- power | |-- name | `-- power |-- irq |-- name |-- power |-- resource |-- subsystem_device |-- subsystem_vendor `-- vendor
and:
$ tree /sys/devices/legacy/i2c-2/ /sys/devices/legacy/i2c-2/ |-- 2-0290 | |-- alarms | |-- beep_enable | |-- beep_mask | |-- fan_div1 | |-- fan_div2 | |-- fan_div3 | |-- fan_input1 | |-- fan_input2 | |-- fan_input3 | |-- fan_min1 | |-- fan_min2 | |-- fan_min3 | |-- in_input0 | |-- in_input1 | |-- in_input2 | |-- in_input3 | |-- in_input4 | |-- in_input5 | |-- in_input6 | |-- in_input7 | |-- in_input8 | |-- in_max0 | |-- in_max1 | |-- in_max2 | |-- in_max3 | |-- in_max4 | |-- in_max5 | |-- in_max6 | |-- in_max7 | |-- in_max8 | |-- in_min0 | |-- in_min1 | |-- in_min2 | |-- in_min3 | |-- in_min4 | |-- in_min5 | |-- in_min6 | |-- in_min7 | |-- in_min8 | |-- name | |-- power | |-- pwm1 | |-- pwm2 | |-- pwm_enable2 | |-- sensor1 | |-- sensor2 | |-- sensor3 | |-- temp_input1 | |-- temp_input2 | |-- temp_input3 | |-- temp_max1 | |-- temp_max2 | |-- temp_max3 | |-- temp_min1 | |-- temp_min2 | |-- temp_min3 | |-- vid | `-- vrm |-- name `-- power
I think the best description of the kernel driver model's use of interconnected structure pointers and representation to the user was issued by Jonathan Corbet: “web woven by a spider on drugs” (lwn.net/Articles/31185/). Hopefully, these two articles have helped you unravel the loony web, showing the true interconnectedness of all devices within the kernel.
I would like to thank Pat Mochel for creating such a powerful and complete framework in which all kernel drivers and devices easily can be shown to the user. Also, a big thanks to all of the kernel driver subsystem maintainers who have gladly converted their subsystems over to this model; without their help, the driver core code would have been little more than a nice academic exercise.
Greg Kroah-Hartman is currently the Linux USB and PCI Hot Plug kernel maintainer. He works for IBM, doing various Linux kernel-related things and can be reached at greg@kroah.com.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.
Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.
Sponsored by ActiveState
| Speed Up Your Web Site with Varnish | Jun 19, 2013 |
| Non-Linux FOSS: libnotify, OS X Style | Jun 18, 2013 |
| Containers—Not Virtual Machines—Are the Future Cloud | Jun 17, 2013 |
| Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer | Jun 12, 2013 |
| Weechat, Irssi's Little Brother | Jun 11, 2013 |
| One Tail Just Isn't Enough | Jun 07, 2013 |
- Speed Up Your Web Site with Varnish
- Containers—Not Virtual Machines—Are the Future Cloud
- Linux Systems Administrator
- Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer
- Non-Linux FOSS: libnotify, OS X Style
- Senior Perl Developer
- Technical Support Rep
- UX Designer
- Web & UI Developer (JavaScript & j Query)
- Android's Limits
- Reply to comment | Linux Journal
54 min 34 sec ago - Yeah, user namespaces are
2 hours 10 min ago - Cari Uang
5 hours 42 min ago - user namespaces
8 hours 35 min ago - yea
9 hours 1 min ago - One advantage with VMs
11 hours 30 min ago - about info
12 hours 3 min ago - info
12 hours 4 min ago - info
12 hours 5 min ago - info
12 hours 7 min ago




Comments
Re: Device Classes
Cool description of sysfs, i wonder if it is possible to describe how a user-space app (kde, gnome, etc) could use it to some benefit for it