Add a type Data<'bound> associated type to all bus driver traits, decoupling the driver's bus device private data type from the driver struct itself. In the context of adding a 'bound lifetime, making this an associated type has the advantage that it allows us to avoid a driver trait global lifetime and it avoids the need for ForLt for bus device private data; both of which make the subsequent implementation by buses much simpler. All existing drivers and doc examples set type Data = Self to preserve the current behavior.
Showing the changes to samples (9 of 22 files). Show all
Unified · Split
| @@ -117,6 +117,7 @@ kernel::acpi_device_table!( · 116 unmodified lines | ||
| 117 | 117 | |
| 118 | 118 | impl platform::Driver for RustDebugFs { |
| 119 | 119 | type IdInfo = (); |
| 120 | + type Data = Self; | |
| 120 | 121 | const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = None; |
| 121 | 122 | const ACPI_ID_TABLE: Option<acpi::IdTable<Self::IdInfo>> = Some(&ACPI_TABLE); |
| 122 | 123 | |
| @@ -58,6 +58,7 @@ kernel::pci_device_table!( · 57 unmodified lines | ||
| 58 | 58 | |
| 59 | 59 | impl pci::Driver for DmaSampleDriver { |
| 60 | 60 | type IdInfo = (); |
| 61 | + type Data = Self; | |
| 61 | 62 | const ID_TABLE: pci::IdTable<Self::IdInfo> = &PCI_TABLE; |
| 62 | 63 | |
| 63 | 64 | fn probe(pdev: &pci::Device<Core>, _info: &Self::IdInfo) -> impl PinInit<Self, Error> { |
| @@ -31,6 +31,7 @@ kernel::auxiliary_device_table!( · 30 unmodified lines | ||
| 31 | 31 | |
| 32 | 32 | impl auxiliary::Driver for AuxiliaryDriver { |
| 33 | 33 | type IdInfo = (); |
| 34 | + type Data = Self; | |
| 34 | 35 | |
| 35 | 36 | const ID_TABLE: auxiliary::IdTable<Self::IdInfo> = &AUX_TABLE; |
| 36 | 37 | |
| @@ -65,6 +66,7 @@ kernel::pci_device_table!( · 28 unmodified lines | ||
| 65 | 66 | |
| 66 | 67 | impl pci::Driver for ParentDriver { |
| 67 | 68 | type IdInfo = (); |
| 69 | + type Data = Self; | |
| 68 | 70 | |
| 69 | 71 | const ID_TABLE: pci::IdTable<Self::IdInfo> = &PCI_TABLE; |
| 70 | 72 | |
| @@ -35,6 +35,7 @@ kernel::of_device_table! { · 34 unmodified lines | ||
| 35 | 35 | |
| 36 | 36 | impl i2c::Driver for SampleDriver { |
| 37 | 37 | type IdInfo = u32; |
| 38 | + type Data = Self; | |
| 38 | 39 | |
| 39 | 40 | const ACPI_ID_TABLE: Option<acpi::IdTable<Self::IdInfo>> = Some(&ACPI_TABLE); |
| 40 | 41 | const I2C_ID_TABLE: Option<i2c::IdTable<Self::IdInfo>> = Some(&I2C_TABLE); |
| @@ -140,6 +140,7 @@ impl SampleDriver { · 139 unmodified lines | ||
| 140 | 140 | |
| 141 | 141 | impl pci::Driver for SampleDriver { |
| 142 | 142 | type IdInfo = TestIndex; |
| 143 | + type Data = Self; | |
| 143 | 144 | |
| 144 | 145 | const ID_TABLE: pci::IdTable<Self::IdInfo> = &PCI_TABLE; |
| 145 | 146 | |
| @@ -101,6 +101,7 @@ kernel::acpi_device_table!( · 100 unmodified lines | ||
| 101 | 101 | |
| 102 | 102 | impl platform::Driver for SampleDriver { |
| 103 | 103 | type IdInfo = Info; |
| 104 | + type Data = Self; | |
| 104 | 105 | const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = Some(&OF_TABLE); |
| 105 | 106 | const ACPI_ID_TABLE: Option<acpi::IdTable<Self::IdInfo>> = Some(&ACPI_TABLE); |
| 106 | 107 | |
| @@ -26,6 +26,7 @@ kernel::usb_device_table!( · 25 unmodified lines | ||
| 26 | 26 | |
| 27 | 27 | impl usb::Driver for SampleDriver { |
| 28 | 28 | type IdInfo = (); |
| 29 | + type Data = Self; | |
| 29 | 30 | const ID_TABLE: usb::IdTable<Self::IdInfo> = &USB_TABLE; |
| 30 | 31 | |
| 31 | 32 | fn probe( |
| @@ -106,6 +106,7 @@ const BOARD_INFO: i2c::I2cBoardInfo = · 105 unmodified lines | ||
| 106 | 106 | |
| 107 | 107 | impl platform::Driver for SampleDriver { |
| 108 | 108 | type IdInfo = (); |
| 109 | + type Data = Self; | |
| 109 | 110 | const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = Some(&OF_TABLE); |
| 110 | 111 | const ACPI_ID_TABLE: Option<acpi::IdTable<Self::IdInfo>> = Some(&ACPI_TABLE); |
| 111 | 112 | |
| @@ -37,6 +37,7 @@ kernel::acpi_device_table!( · 36 unmodified lines | ||
| 37 | 37 | |
| 38 | 38 | impl platform::Driver for SampleSocDriver { |
| 39 | 39 | type IdInfo = (); |
| 40 | + type Data = Self; | |
| 40 | 41 | const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = Some(&OF_TABLE); |
| 41 | 42 | const ACPI_ID_TABLE: Option<acpi::IdTable<Self::IdInfo>> = Some(&ACPI_TABLE); |
| 42 | 43 | |