Devres in kernel::devres
Devres is a wrapper for anything a driver borrows from its hardware, such as a mapped block of registers. You hand the resource to Devres along with the device, and the kernel guarantees it is releas…
Anything a driver takes from the hardware, a register mapping, an interrupt line, a memory region, must be given back when the device goes away, and in the right order. Device-managed resources attach the cleanup to the device itself, so it happens automatically at unbind even if your code returned early from probe three steps in. In Rust the wrapper also revokes access, so a handle that outlives the device cannot be used rather than quietly pointing at unmapped memory. This is the rule that replaces the long C teardown ladder and the leaks it hides.
Devres is a wrapper for anything a driver borrows from its hardware, such as a mapped block of registers. You hand the resource to Devres along with the device, and the kernel guarantees it is releas…