From e7755b5f29ccbfd1222dd52dc2d6eebf39d02289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Antinori?= Date: Mon, 19 Oct 2026 12:23:15 -0300 Subject: rust: i2c: remove TryFrom<&Device> implementation for &I2cClient MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the `TryFrom<&device::Device>` implementation for `&I2cClient` since it has had no users since its introduction. Fixes: 57c5bd9aee94 ("rust: i2c: add basic I2C device and driver abstractions") Reported-by: Georgios Androutsopoulos Closes: https://github.com/Rust-for-Linux/linux/issues/1264 Signed-off-by: Nicolás Antinori Signed-off-by: Igor Korotin --- rust/kernel/i2c.rs | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'rust') 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 AsRef> for I2cClient { } } -impl TryFrom<&device::Device> for &I2cClient { - type Error = kernel::error::Error; - - fn try_from(dev: &device::Device) -> Result { - // 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 {} -- cgit v1.2.3