diff options
| author | Andi Shyti <andi.shyti@kernel.org> | 2026-10-23 18:36:39 +0200 |
|---|---|---|
| committer | Andi Shyti <andi.shyti@kernel.org> | 2026-10-23 18:36:39 +0200 |
| commit | f0e53c16b1562f06775e46ceb263b72785363674 (patch) | |
| tree | ba251dfd5b24dad9cc3dcbcbaf3aa6f9a63841af /rust | |
| parent | c2867bb0fa1dd1932a7a382b44df376d2085a66f (diff) | |
| parent | e7755b5f29ccbfd1222dd52dc2d6eebf39d02289 (diff) | |
Merge tag 'rust-i2c-for-7.4' into i2c/i2c
A single fix for the Rust I2C abstractions
* tag 'rust-i2c-for-7.4':
rust: i2c: remove TryFrom<&Device> implementation for &I2cClient
Diffstat (limited to 'rust')
| -rw-r--r-- | rust/kernel/i2c.rs | 21 |
1 files changed, 0 insertions, 21 deletions
diff --git a/rust/kernel/i2c.rs b/rust/kernel/i2c.rs index 0487bae811fb..b4ff25c830fc 100644 --- a/rust/kernel/i2c.rs +++ b/rust/kernel/i2c.rs @@ -5,7 +5,6 @@ // I2C Driver abstractions. use crate::{ acpi, - container_of, device, device_id::{ RawDeviceId, @@ -517,26 +516,6 @@ impl<Ctx: device::DeviceContext> AsRef<device::Device<Ctx>> for I2cClient<Ctx> { } } -impl<Ctx: device::DeviceContext> TryFrom<&device::Device<Ctx>> for &I2cClient<Ctx> { - type Error = kernel::error::Error; - - fn try_from(dev: &device::Device<Ctx>) -> Result<Self, Self::Error> { - // SAFETY: By the type invariant of `Device`, `dev.as_raw()` is a valid pointer to a - // `struct device`. - if unsafe { bindings::i2c_verify_client(dev.as_raw()).is_null() } { - return Err(EINVAL); - } - - // SAFETY: We've just verified that the type of `dev` equals to - // `bindings::i2c_client_type`, hence `dev` must be embedded in a valid - // `struct i2c_client` as guaranteed by the corresponding C code. - let idev = unsafe { container_of!(dev.as_raw(), bindings::i2c_client, dev) }; - - // SAFETY: `idev` is a valid pointer to a `struct i2c_client`. - Ok(unsafe { &*idev.cast() }) - } -} - // SAFETY: A `I2cClient` is always reference-counted and can be released from any thread. unsafe impl Send for I2cClient {} |
