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