<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/rust/kernel/i2c.rs, branch v6.19-rc2</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>rust: i2c: prepare for `core::ffi::CStr`</title>
<updated>2025-11-23T20:14:47+00:00</updated>
<author>
<name>Miguel Ojeda</name>
<email>ojeda@kernel.org</email>
</author>
<published>2025-11-23T16:35:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=a762f883ecf6eed3c0c57e7afa97fba09287a40a'/>
<id>a762f883ecf6eed3c0c57e7afa97fba09287a40a</id>
<content type='text'>
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 `&amp;'static ffi::CStr` in the current scope
      --&gt; rust/kernel/i2c.rs:48:16
       |
    48 |             id.len_with_nul() &lt;= Self::I2C_NAME_SIZE,
       |                ^^^^^^^^^^^^ method not found in `&amp;CStr`

    error[E0599]: no method named `as_bytes_with_nul` found for reference `&amp;'static ffi::CStr` in the current scope
      --&gt; 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/ [1]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
Link: https://patch.msgid.link/20251123163536.1771801-1-ojeda@kernel.org
Signed-off-by: Danilo Krummrich &lt;dakr@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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 `&amp;'static ffi::CStr` in the current scope
      --&gt; rust/kernel/i2c.rs:48:16
       |
    48 |             id.len_with_nul() &lt;= Self::I2C_NAME_SIZE,
       |                ^^^^^^^^^^^^ method not found in `&amp;CStr`

    error[E0599]: no method named `as_bytes_with_nul` found for reference `&amp;'static ffi::CStr` in the current scope
      --&gt; 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/ [1]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
Link: https://patch.msgid.link/20251123163536.1771801-1-ojeda@kernel.org
Signed-off-by: Danilo Krummrich &lt;dakr@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>rust: Add trait to convert a device reference to a bus device reference</title>
<updated>2025-11-17T22:00:51+00:00</updated>
<author>
<name>Markus Probst</name>
<email>markus.probst@posteo.de</email>
</author>
<published>2025-10-27T20:06:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=e4addc7cc2dfcc19f1c8c8e47f3834b22cb21559'/>
<id>e4addc7cc2dfcc19f1c8c8e47f3834b22cb21559</id>
<content type='text'>
Implement the `AsBusDevice` trait for converting a `Device` reference to a
bus device reference for all bus devices.

The `AsBusDevice` trait allows abstractions to provide the bus device in
class device callbacks. It must not be used by drivers and is intended for
bus and class device abstractions only.

Signed-off-by: Markus Probst &lt;markus.probst@posteo.de&gt;
Link: https://patch.msgid.link/20251027200547.1038967-2-markus.probst@posteo.de
[ * Remove unused import.
  * Change visibility of AsBusDevice to public.
  * Fix build for USB.
  * Add impl for I2cClient.
  - Danilo ]
Signed-off-by: Danilo Krummrich &lt;dakr@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Implement the `AsBusDevice` trait for converting a `Device` reference to a
bus device reference for all bus devices.

The `AsBusDevice` trait allows abstractions to provide the bus device in
class device callbacks. It must not be used by drivers and is intended for
bus and class device abstractions only.

Signed-off-by: Markus Probst &lt;markus.probst@posteo.de&gt;
Link: https://patch.msgid.link/20251027200547.1038967-2-markus.probst@posteo.de
[ * Remove unused import.
  * Change visibility of AsBusDevice to public.
  * Fix build for USB.
  * Add impl for I2cClient.
  - Danilo ]
Signed-off-by: Danilo Krummrich &lt;dakr@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>rust: i2c: add manual I2C device creation abstractions</title>
<updated>2025-11-17T21:28:19+00:00</updated>
<author>
<name>Igor Korotin</name>
<email>igor.korotin.linux@gmail.com</email>
</author>
<published>2025-11-16T16:21:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=f3cc26a417b77a07ff4418f7621dd318a1c533b1'/>
<id>f3cc26a417b77a07ff4418f7621dd318a1c533b1</id>
<content type='text'>
In addition to the basic I2C device support, add rust abstractions
upon `i2c_new_client_device`/`i2c_unregister_device` C functions.

Implement the core abstractions needed for manual creation/deletion
of I2C devices, including:

 * `i2c::Registration` — a NonNull pointer created by the function
                          `i2c_new_client_device`

 * `i2c::I2cAdapter` — a ref counted wrapper around `struct i2c_adapter`

 * `i2c::I2cBoardInfo` — a safe wrapper around `struct i2c_board_info`

Acked-by: Wolfram Sang &lt;wsa+renesas@sang-engineering.com&gt;
Signed-off-by: Igor Korotin &lt;igor.korotin.linux@gmail.com&gt;
Link: https://patch.msgid.link/20251116162154.171493-1-igor.korotin.linux@gmail.com
[ Remove unnecessary safety comment. - Danilo ]
Signed-off-by: Danilo Krummrich &lt;dakr@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In addition to the basic I2C device support, add rust abstractions
upon `i2c_new_client_device`/`i2c_unregister_device` C functions.

Implement the core abstractions needed for manual creation/deletion
of I2C devices, including:

 * `i2c::Registration` — a NonNull pointer created by the function
                          `i2c_new_client_device`

 * `i2c::I2cAdapter` — a ref counted wrapper around `struct i2c_adapter`

 * `i2c::I2cBoardInfo` — a safe wrapper around `struct i2c_board_info`

Acked-by: Wolfram Sang &lt;wsa+renesas@sang-engineering.com&gt;
Signed-off-by: Igor Korotin &lt;igor.korotin.linux@gmail.com&gt;
Link: https://patch.msgid.link/20251116162154.171493-1-igor.korotin.linux@gmail.com
[ Remove unnecessary safety comment. - Danilo ]
Signed-off-by: Danilo Krummrich &lt;dakr@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>rust: i2c: add basic I2C device and driver abstractions</title>
<updated>2025-11-17T21:26:42+00:00</updated>
<author>
<name>Igor Korotin</name>
<email>igor.korotin.linux@gmail.com</email>
</author>
<published>2025-11-16T16:21:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=57c5bd9aee944b0f5c2ab314e10a86fae51f7bf2'/>
<id>57c5bd9aee944b0f5c2ab314e10a86fae51f7bf2</id>
<content type='text'>
Implement the core abstractions needed for I2C drivers, including:

* `i2c::Driver` — the trait drivers must implement, including `probe`

* `i2c::I2cClient` — a safe wrapper around `struct i2c_client`

* `i2c::Adapter` — implements `driver::RegistrationOps` to hook into the
  generic `driver::Registration` machinery

* `i2c::DeviceId` — a `RawDeviceIdIndex` implementation for I2C device IDs

Acked-by: Wolfram Sang &lt;wsa+renesas@sang-engineering.com&gt;
Signed-off-by: Igor Korotin &lt;igor.korotin.linux@gmail.com&gt;
Link: https://patch.msgid.link/20251116162144.171469-1-igor.korotin.linux@gmail.com
[ Remove unnecessary safety comment; fix rustdoc `Device` -&gt; `I2cClient`.
  - Danilo ]
Signed-off-by: Danilo Krummrich &lt;dakr@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Implement the core abstractions needed for I2C drivers, including:

* `i2c::Driver` — the trait drivers must implement, including `probe`

* `i2c::I2cClient` — a safe wrapper around `struct i2c_client`

* `i2c::Adapter` — implements `driver::RegistrationOps` to hook into the
  generic `driver::Registration` machinery

* `i2c::DeviceId` — a `RawDeviceIdIndex` implementation for I2C device IDs

Acked-by: Wolfram Sang &lt;wsa+renesas@sang-engineering.com&gt;
Signed-off-by: Igor Korotin &lt;igor.korotin.linux@gmail.com&gt;
Link: https://patch.msgid.link/20251116162144.171469-1-igor.korotin.linux@gmail.com
[ Remove unnecessary safety comment; fix rustdoc `Device` -&gt; `I2cClient`.
  - Danilo ]
Signed-off-by: Danilo Krummrich &lt;dakr@kernel.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
