Lines Matching +full:generic +full:- +full:2
12 Please refer to `Documentation/driver-api/driver-model/*.rst` for definitions of
21 be embedded in larger, bus-specific objects. Fields in these generic
22 objects can replace fields in the bus-specific objects.
24 The generic objects must be registered with the driver model core. By
28 # mount -t sysfs sysfs /sys
39 - Define a struct bus_type for the bus driver::
46 - Register the bus type.
65 - Export the bus type for others to use.
81 - This will cause the bus to show up in /sys/bus/pci/ with two
84 # tree -d /sys/bus/pci/
86 |-- devices
87 `-- drivers
91 Step 2: Registering Devices.
97 - Embed a struct device in the bus-specific device type::
102 struct device dev; /* Generic device interface */
106 It is recommended that the generic device not be the first item in
109 should be created to convert from the generic object type::
121 This allows the compiler to verify type-safety of the operations
125 - Initialize the device on registration.
128 bus driver should initialize the generic device. The most important
132 the bus. The format of this string is bus-specific. This is
165 - Register the device.
167 Once the generic device has been initialized, it can be registered
170 device_register(&dev->dev);
174 device_unregister(&dev->dev);
179 device's release method, then free the bus-specific object.
189 |-- 00:00.0
190 |-- 00:01.0
191 | `-- 01:00.0
192 |-- 00:02.0
193 | `-- 02:1f.0
194 | `-- 03:00.0
195 |-- 00:1e.0
196 | `-- 04:04.0
197 |-- 00:1f.0
198 |-- 00:1f.1
199 | |-- ide0
200 | | |-- 0.0
201 | | `-- 0.1
202 | `-- ide1
203 | `-- 1.0
204 |-- 00:1f.2
205 |-- 00:1f.3
206 `-- 00:1f.5
212 |-- 00:00.0 -> ../../../devices/pci0/00:00.0
213 |-- 00:01.0 -> ../../../devices/pci0/00:01.0
214 |-- 00:02.0 -> ../../../devices/pci0/00:02.0
215 |-- 00:1e.0 -> ../../../devices/pci0/00:1e.0
216 |-- 00:1f.0 -> ../../../devices/pci0/00:1f.0
217 |-- 00:1f.1 -> ../../../devices/pci0/00:1f.1
218 |-- 00:1f.2 -> ../../../devices/pci0/00:1f.2
219 |-- 00:1f.3 -> ../../../devices/pci0/00:1f.3
220 |-- 00:1f.5 -> ../../../devices/pci0/00:1f.5
221 |-- 01:00.0 -> ../../../devices/pci0/00:01.0/01:00.0
222 |-- 02:1f.0 -> ../../../devices/pci0/00:02.0/02:1f.0
223 |-- 03:00.0 -> ../../../devices/pci0/00:02.0/02:1f.0/03:00.0
224 `-- 04:04.0 -> ../../../devices/pci0/00:1e.0/04:04.0
234 - Embed a struct device_driver in the bus-specific driver.
244 - Initialize the generic driver structure.
251 - Register the driver.
253 After the generic driver has been initialized, call::
255 driver_register(&drv->driver);
262 driver_unregister(&drv->driver);
268 - Sysfs representation.
274 |-- 3c59x
275 |-- Ensoniq AudioPCI
276 |-- agpgart-amdk7
277 |-- e100
278 `-- serial
281 Step 4: Define Generic Methods for Drivers.
289 simultaneously convert their drivers to generic format. Instead, the
290 bus driver should define single instances of the generic methods that
291 forward call to the bus-specific drivers. For instance::
297 struct pci_driver * drv = pci_dev->driver;
300 if (drv->remove)
301 drv->remove(pci_dev);
302 pci_dev->driver = NULL;
308 The generic driver should be initialized with these methods before it
312 drv->driver.name = drv->name;
313 drv->driver.bus = &pci_bus_type;
314 drv->driver.probe = pci_device_probe;
315 drv->driver.resume = pci_device_resume;
316 drv->driver.suspend = pci_device_suspend;
317 drv->driver.remove = pci_device_remove;
320 driver_register(&drv->driver);
324 already set. This allows the drivers to implement their own generic
328 Step 5: Support generic driver binding.
338 bus-specific, so the generic model does attempt to generalize them.
347 -EPROBE_DEFER) if determining that given driver supports the device is
351 over. bus->match() is called for each one until a match is found.
354 over. bus->match() is called for each device that is not already
357 When a device is successfully bound to a driver, device->driver is
358 set, the device is added to a per-driver list of devices, and a
363 |-- 3c59x
364 | `-- 00:0b.0 -> ../../../../devices/pci0/00:0b.0
365 |-- Ensoniq AudioPCI
366 |-- agpgart-amdk7
367 | `-- 00:00.0 -> ../../../../devices/pci0/00:00.0
368 |-- e100
369 | `-- 00:0c.0 -> ../../../../devices/pci0/00:0c.0
370 `-- serial
387 - ACTION: set to 'add' or 'remove'
388 - DEVPATH: set to the device's physical path in sysfs.
402 The generic bus, device, and driver structures provide several fields
405 - Device list.
418 - Driver list.
422 be removed in favor of using the generic one.
433 - rwsem
441 - Device and driver fields.
444 fields in the bus-specific representations of these objects. Feel free
445 to remove the bus-specific ones and favor the generic ones. Note
447 reference the bus-specific fields (though those should all be 1-line