History

rust: driver: decouple driver private data from driver type

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.

Danilo Krummrich committed 5 months ago

Commit 7fdffdd1 parent c8a436622 files · +98 −55Browse files

Showing the changes to samples (9 of 22 files). Show all

Unified · Split

9 files
  1. samples/rust/rust_debugfs.rs +1 −0
  2. samples/rust/rust_dma.rs +1 −0
  3. samples/rust/rust_driver_auxiliary.rs +2 −0
  4. samples/rust/rust_driver_i2c.rs +1 −0
  5. samples/rust/rust_driver_pci.rs +1 −0
  6. samples/rust/rust_driver_platform.rs +1 −0
  7. samples/rust/rust_driver_usb.rs +1 −0
  8. samples/rust/rust_i2c_client.rs +1 −0
  9. samples/rust/rust_soc.rs +1 −0
samples/rust/rust_debugfs.rs+1−0
@@ -117,6 +117,7 @@ kernel::acpi_device_table!( · 116 unmodified lines
117117
118118 impl platform::Driver for RustDebugFs {
119119 type IdInfo = ();
120+ type Data = Self;
120121 const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = None;
121122 const ACPI_ID_TABLE: Option<acpi::IdTable<Self::IdInfo>> = Some(&ACPI_TABLE);
122123
samples/rust/rust_dma.rs+1−0
@@ -58,6 +58,7 @@ kernel::pci_device_table!( · 57 unmodified lines
5858
5959 impl pci::Driver for DmaSampleDriver {
6060 type IdInfo = ();
61+ type Data = Self;
6162 const ID_TABLE: pci::IdTable<Self::IdInfo> = &PCI_TABLE;
6263
6364 fn probe(pdev: &pci::Device<Core>, _info: &Self::IdInfo) -> impl PinInit<Self, Error> {
samples/rust/rust_driver_auxiliary.rs+2−0
@@ -31,6 +31,7 @@ kernel::auxiliary_device_table!( · 30 unmodified lines
3131
3232 impl auxiliary::Driver for AuxiliaryDriver {
3333 type IdInfo = ();
34+ type Data = Self;
3435
3536 const ID_TABLE: auxiliary::IdTable<Self::IdInfo> = &AUX_TABLE;
3637
@@ -65,6 +66,7 @@ kernel::pci_device_table!( · 28 unmodified lines
6566
6667 impl pci::Driver for ParentDriver {
6768 type IdInfo = ();
69+ type Data = Self;
6870
6971 const ID_TABLE: pci::IdTable<Self::IdInfo> = &PCI_TABLE;
7072
samples/rust/rust_driver_i2c.rs+1−0
@@ -35,6 +35,7 @@ kernel::of_device_table! { · 34 unmodified lines
3535
3636 impl i2c::Driver for SampleDriver {
3737 type IdInfo = u32;
38+ type Data = Self;
3839
3940 const ACPI_ID_TABLE: Option<acpi::IdTable<Self::IdInfo>> = Some(&ACPI_TABLE);
4041 const I2C_ID_TABLE: Option<i2c::IdTable<Self::IdInfo>> = Some(&I2C_TABLE);
samples/rust/rust_driver_pci.rs+1−0
@@ -140,6 +140,7 @@ impl SampleDriver { · 139 unmodified lines
140140
141141 impl pci::Driver for SampleDriver {
142142 type IdInfo = TestIndex;
143+ type Data = Self;
143144
144145 const ID_TABLE: pci::IdTable<Self::IdInfo> = &PCI_TABLE;
145146
samples/rust/rust_driver_platform.rs+1−0
@@ -101,6 +101,7 @@ kernel::acpi_device_table!( · 100 unmodified lines
101101
102102 impl platform::Driver for SampleDriver {
103103 type IdInfo = Info;
104+ type Data = Self;
104105 const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = Some(&OF_TABLE);
105106 const ACPI_ID_TABLE: Option<acpi::IdTable<Self::IdInfo>> = Some(&ACPI_TABLE);
106107
samples/rust/rust_driver_usb.rs+1−0
@@ -26,6 +26,7 @@ kernel::usb_device_table!( · 25 unmodified lines
2626
2727 impl usb::Driver for SampleDriver {
2828 type IdInfo = ();
29+ type Data = Self;
2930 const ID_TABLE: usb::IdTable<Self::IdInfo> = &USB_TABLE;
3031
3132 fn probe(
samples/rust/rust_i2c_client.rs+1−0
@@ -106,6 +106,7 @@ const BOARD_INFO: i2c::I2cBoardInfo = · 105 unmodified lines
106106
107107 impl platform::Driver for SampleDriver {
108108 type IdInfo = ();
109+ type Data = Self;
109110 const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = Some(&OF_TABLE);
110111 const ACPI_ID_TABLE: Option<acpi::IdTable<Self::IdInfo>> = Some(&ACPI_TABLE);
111112
samples/rust/rust_soc.rs+1−0
@@ -37,6 +37,7 @@ kernel::acpi_device_table!( · 36 unmodified lines
3737
3838 impl platform::Driver for SampleSocDriver {
3939 type IdInfo = ();
40+ type Data = Self;
4041 const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = Some(&OF_TABLE);
4142 const ACPI_ID_TABLE: Option<acpi::IdTable<Self::IdInfo>> = Some(&ACPI_TABLE);
4243