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
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
- Dynamic DNS—an Object Lesson in Problem Solving
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- Drupal Is a Framework: Why Everyone Needs to Understand This
- Validate an E-Mail Address with PHP, the Right Way
- A Topic for Discussion - Open Source Feature-Richness?
- Download the Free Red Hat White Paper "Using an Open Source Framework to Catch the Bad Guy"
- Dart: a New Web Programming Experience
- New Products
- myip
2 hours 11 min ago - Keeping track of IP address
4 hours 2 min ago - Roll your own dynamic dns
9 hours 16 min ago - Please correct the URL for Salt Stack's web site
12 hours 27 min ago - Android is Linux -- why no better inter-operation
14 hours 42 min ago - Connecting Android device to desktop Linux via USB
15 hours 11 min ago - Find new cell phone and tablet pc
16 hours 9 min ago - Epistle
17 hours 38 min ago - Automatically updating Guest Additions
18 hours 46 min ago - I like your topic on android
19 hours 33 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