diff options
| author | Nicolás Antinori <nico.antinori.7@gmail.com> | 2026-10-19 12:23:15 -0300 |
|---|---|---|
| committer | Igor Korotin <igor.korotin@linux.dev> | 2026-10-21 17:47:21 +0100 |
| commit | e7755b5f29ccbfd1222dd52dc2d6eebf39d02289 (patch) | |
| tree | 45c2b5d8facf6bc48c9f9baebafec0b146a86eb5 /rust/kernel | |
| parent | 0f6be986ad0eb6fe7338d963a14eaf0dee87677d (diff) | |
| download | linux-next-e7755b5f29ccbfd1222dd52dc2d6eebf39d02289.tar.gz linux-next-e7755b5f29ccbfd1222dd52dc2d6eebf39d02289.zip | |
rust: i2c: remove TryFrom<&Device> implementation for &I2cClient
Remove the `TryFrom<&device::Device<Ctx>>` implementation for
`&I2cClient<Ctx>` since it has had no users since its introduction.
Fixes: 57c5bd9aee94 ("rust: i2c: add basic I2C device and driver abstractions")
Reported-by: Georgios Androutsopoulos <georgeandrout13@gmail.com>
Closes: https://github.com/Rust-for-Linux/linux/issues/1264
Signed-off-by: Nicolás Antinori <nico.antinori.7@gmail.com>
Signed-off-by: Igor Korotin <igor.korotin@linux.dev>
Diffstat (limited to 'rust/kernel')
| -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 {} |
