summaryrefslogtreecommitdiff
path: root/rust/kernel/i2c.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/kernel/i2c.rs')
-rw-r--r--rust/kernel/i2c.rs21
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 {}