aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/driver-model/overview.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/driver-model/overview.txt')
-rw-r--r--Documentation/driver-model/overview.txt52
1 files changed, 34 insertions, 18 deletions
diff --git a/Documentation/driver-model/overview.txt b/Documentation/driver-model/overview.txt
index 07236ed968da..6a8f9a8075d8 100644
--- a/Documentation/driver-model/overview.txt
+++ b/Documentation/driver-model/overview.txt
@@ -30,7 +30,7 @@ management, and hot plug. In particular, the model dictated by Intel and
30Microsoft (namely ACPI) ensures that almost every device on almost any bus 30Microsoft (namely ACPI) ensures that almost every device on almost any bus
31on an x86-compatible system can work within this paradigm. Of course, 31on an x86-compatible system can work within this paradigm. Of course,
32not every bus is able to support all such operations, although most 32not every bus is able to support all such operations, although most
33buses support a most of those operations. 33buses support most of those operations.
34 34
35 35
36Downstream Access 36Downstream Access
@@ -46,25 +46,29 @@ struct pci_dev now looks like this:
46struct pci_dev { 46struct pci_dev {
47 ... 47 ...
48 48
49 struct device dev; 49 struct device dev; /* Generic device interface */
50 ...
50}; 51};
51 52
52Note first that it is statically allocated. This means only one allocation on 53Note first that the struct device dev within the struct pci_dev is
53device discovery. Note also that it is at the _end_ of struct pci_dev. This is 54statically allocated. This means only one allocation on device discovery.
54to make people think about what they're doing when switching between the bus 55
55driver and the global driver; and to prevent against mindless casts between 56Note also that that struct device dev is not necessarily defined at the
56the two. 57front of the pci_dev structure. This is to make people think about what
58they're doing when switching between the bus driver and the global driver,
59and to discourage meaningless and incorrect casts between the two.
57 60
58The PCI bus layer freely accesses the fields of struct device. It knows about 61The PCI bus layer freely accesses the fields of struct device. It knows about
59the structure of struct pci_dev, and it should know the structure of struct 62the structure of struct pci_dev, and it should know the structure of struct
60device. Individual PCI device drivers that have been converted to the current 63device. Individual PCI device drivers that have been converted to the current
61driver model generally do not and should not touch the fields of struct device, 64driver model generally do not and should not touch the fields of struct device,
62unless there is a strong compelling reason to do so. 65unless there is a compelling reason to do so.
63 66
64This abstraction is prevention of unnecessary pain during transitional phases. 67The above abstraction prevents unnecessary pain during transitional phases.
65If the name of the field changes or is removed, then every downstream driver 68If it were not done this way, then when a field was renamed or removed, every
66will break. On the other hand, if only the bus layer (and not the device 69downstream driver would break. On the other hand, if only the bus layer
67layer) accesses struct device, it is only that layer that needs to change. 70(and not the device layer) accesses the struct device, it is only the bus
71layer that needs to change.
68 72
69 73
70User Interface 74User Interface
@@ -73,15 +77,27 @@ User Interface
73By virtue of having a complete hierarchical view of all the devices in the 77By virtue of having a complete hierarchical view of all the devices in the
74system, exporting a complete hierarchical view to userspace becomes relatively 78system, exporting a complete hierarchical view to userspace becomes relatively
75easy. This has been accomplished by implementing a special purpose virtual 79easy. This has been accomplished by implementing a special purpose virtual
76file system named sysfs. It is hence possible for the user to mount the 80file system named sysfs.
77whole sysfs filesystem anywhere in userspace. 81
82Almost all mainstream Linux distros mount this filesystem automatically; you
83can see some variation of the following in the output of the "mount" command:
84
85$ mount
86...
87none on /sys type sysfs (rw,noexec,nosuid,nodev)
88...
89$
90
91The auto-mounting of sysfs is typically accomplished by an entry similar to
92the following in the /etc/fstab file:
93
94none /sys sysfs defaults 0 0
78 95
79This can be done permanently by providing the following entry into the 96or something similar in the /lib/init/fstab file on Debian-based systems:
80/etc/fstab (under the provision that the mount point does exist, of course):
81 97
82none /sys sysfs defaults 0 0 98none /sys sysfs nodev,noexec,nosuid 0 0
83 99
84Or by hand on the command line: 100If sysfs is not automatically mounted, you can always do it manually with:
85 101
86# mount -t sysfs sysfs /sys 102# mount -t sysfs sysfs /sys
87 103