| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | .\" $NetBSD: driver.9,v 1.32 2017/11/17 07:42:29 wiz Exp $ | | 1 | .\" $NetBSD: driver.9,v 1.33 2022/02/11 23:19:34 riastradh Exp $ |
2 | .\" | | 2 | .\" |
3 | .\" Copyright (c) 2001 The NetBSD Foundation, Inc. | | 3 | .\" Copyright (c) 2001 The NetBSD Foundation, Inc. |
4 | .\" All rights reserved. | | 4 | .\" All rights reserved. |
5 | .\" | | 5 | .\" |
6 | .\" This code is derived from software contributed to The NetBSD Foundation | | 6 | .\" This code is derived from software contributed to The NetBSD Foundation |
7 | .\" by Gregory McGarry. | | 7 | .\" by Gregory McGarry. |
8 | .\" | | 8 | .\" |
9 | .\" Redistribution and use in source and binary forms, with or without | | 9 | .\" Redistribution and use in source and binary forms, with or without |
10 | .\" modification, are permitted provided that the following conditions | | 10 | .\" modification, are permitted provided that the following conditions |
11 | .\" are met: | | 11 | .\" are met: |
12 | .\" 1. Redistributions of source code must retain the above copyright | | 12 | .\" 1. Redistributions of source code must retain the above copyright |
13 | .\" notice, this list of conditions and the following disclaimer. | | 13 | .\" notice, this list of conditions and the following disclaimer. |
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | | 14 | .\" 2. Redistributions in binary form must reproduce the above copyright |
| @@ -91,34 +91,26 @@ structure should adopt the standard | | | @@ -91,34 +91,26 @@ structure should adopt the standard |
91 | configuration and naming conventions. | | 91 | configuration and naming conventions. |
92 | For example, the | | 92 | For example, the |
93 | .Em softc | | 93 | .Em softc |
94 | structure for driver | | 94 | structure for driver |
95 | .Dq foo | | 95 | .Dq foo |
96 | is defined with: | | 96 | is defined with: |
97 | .Bd -literal | | 97 | .Bd -literal |
98 | struct foo_softc { | | 98 | struct foo_softc { |
99 | device_t sc_dev; /* generic device info */ | | 99 | device_t sc_dev; /* generic device info */ |
100 | /* device-specific state */ | | 100 | /* device-specific state */ |
101 | }; | | 101 | }; |
102 | .Ed | | 102 | .Ed |
103 | .Pp | | 103 | .Pp |
104 | The autoconfiguration framework mandates that the first member of the | | | |
105 | .Em softc | | | |
106 | structure must be the driver-independent | | | |
107 | .Em device_t . | | | |
108 | Probably its most useful aspect to the driver is that it contains the | | | |
109 | device-instance name | | | |
110 | .Em dv_xname . | | | |
111 | .Pp | | | |
112 | If a driver has character device interfaces accessed from userland, the driver | | 104 | If a driver has character device interfaces accessed from userland, the driver |
113 | must define the | | 105 | must define the |
114 | .Em cdevsw | | 106 | .Em cdevsw |
115 | structure. | | 107 | structure. |
116 | The structure is constant and is defined inside the driver. | | 108 | The structure is constant and is defined inside the driver. |
117 | For example, the | | 109 | For example, the |
118 | .Em cdevsw | | 110 | .Em cdevsw |
119 | structure for driver | | 111 | structure for driver |
120 | .Dq foo | | 112 | .Dq foo |
121 | is defined with: | | 113 | is defined with: |
122 | .Bd -literal | | 114 | .Bd -literal |
123 | const struct cdevsw foo_cdevsw { | | 115 | const struct cdevsw foo_cdevsw { |
124 | int (*d_open)(dev_t, int, int, struct lwp *); | | 116 | int (*d_open)(dev_t, int, int, struct lwp *); |