]> git.ipfire.org Git - thirdparty/linux.git/commit
rust: i2c: prepare for `core::ffi::CStr`
authorMiguel Ojeda <ojeda@kernel.org>
Sun, 23 Nov 2025 16:35:36 +0000 (17:35 +0100)
committerDanilo Krummrich <dakr@kernel.org>
Sun, 23 Nov 2025 20:14:47 +0000 (09:14 +1300)
commita762f883ecf6eed3c0c57e7afa97fba09287a40a
treee0866ace4545eaeb70a84f3eae6cadc2b003544a
parent4635406417bb842862d6322c461743c9b128c444
rust: i2c: prepare for `core::ffi::CStr`

The rust-next tree contains commit:

    3b83f5d5e78a ("rust: replace `CStr` with `core::ffi::CStr`")

which, when merged together with commits:

    57c5bd9aee94 ("rust: i2c: add basic I2C device and driver abstractions")
    f3cc26a417b7 ("rust: i2c: add manual I2C device creation abstractions")

from this tree (driver-core), produces errors like the following:

    error[E0599]: no method named `len_with_nul` found for reference `&'static ffi::CStr` in the current scope
      --> rust/kernel/i2c.rs:48:16
       |
    48 |             id.len_with_nul() <= Self::I2C_NAME_SIZE,
       |                ^^^^^^^^^^^^ method not found in `&CStr`

    error[E0599]: no method named `as_bytes_with_nul` found for reference `&'static ffi::CStr` in the current scope
      --> rust/kernel/i2c.rs:51:22
       |
    51 |         let src = id.as_bytes_with_nul();
       |                      ^^^^^^^^^^^^^^^^^
       |
    help: there is a method `to_bytes_with_nul` with a similar name
       |
    51 |         let src = id.to_bytes_with_nul();
       |                      ~~~~~~~~~~~~~~~~~

which were detected in linux-next by Stephen [1].

The `i2c` code can be independently prepared to be ready for the change,
thus do so.

The change is similar to the one done by Tamir in commit 657403637f7d
("rust: acpi: use `core::ffi::CStr` method names").

Link: https://lore.kernel.org/all/20251120181111.65ce75a0@canb.auug.org.au/
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Link: https://patch.msgid.link/20251123163536.1771801-1-ojeda@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
rust/kernel/i2c.rs