XenevaOS
Loading...
Searching...
No Matches
driver.h
Go to the documentation of this file.
1#ifndef __LINUX_DEVICE_DRIVER_H__
2#define __LINUX_DEVICE_DRIVER_H__
3
4/*
5 * DCL <linux/device/driver.h> -- upstream's home for struct device_driver,
6 * in the one shape DCL can lay out.
7 *
8 * The struct used to be defined in <linux/virtio.h>, because virtio_driver
9 * was the first bus driver that needed to write `.driver.name` and that is
10 * where the flattened bytes happened to live. pci_driver needs it now --
11 * bochs.c initialises `.driver.pm` -- and a second definition under a second
12 * header is a landmine that goes off the day a translation unit includes
13 * both buses. The vendored virtio-gpu driver (next up after the scanout
14 * stage) is exactly that translation unit: virtgpu_drv.c includes
15 * <linux/pci.h> and reaches <linux/virtio.h> through its own header. So the
16 * tag moved to upstream's path and both buses include it from here.
17 *
18 * Layout promises, in the order they bind:
19 *
20 * - `name` stays at offset 0. `.driver.name = KBUILD_MODNAME` relies on it
21 * (virtio-rng.c, virtio_console.c) and the prebuilt modules were
22 * assembled against it.
23 *
24 * - the struct stays 152 bytes. virtio_driver's own members sit after the
25 * whole struct -- id_table at 152, probe at 200 -- so a size change would
26 * move every one of them. `_rest` is what pins the size, and `pm` took
27 * its eight bytes out of it.
28 *
29 * - `pm` is the only named member besides `name`. mainline continues with
30 * bus, owner, mod_name, probe, the of/acpi match tables and the rest of
31 * the bind machinery; all of those would be permanently-NULL members
32 * nothing in this tree reads. When one is actually needed it gets
33 * promoted out of `_rest` the same way `pm` did -- that is what the
34 * padding is for.
35 */
36
37struct dev_pm_ops;
38
40 const char* name;
41 const struct dev_pm_ops* pm;
42 unsigned char _rest[136];
43};
44
45#endif /* __LINUX_DEVICE_DRIVER_H__ */
Definition pm.h:71
Definition driver.h:39
const struct dev_pm_ops * pm
Definition driver.h:41
const char * name
Definition driver.h:40
unsigned char _rest[136]
Definition driver.h:42