From fd1ba03e2272f458bb5d956d44dfd11415cd0ea5 Mon Sep 17 00:00:00 2001 From: Jan Niehusmann Date: Tue, 21 Oct 2025 19:31:04 +0000 Subject: [PATCH 1/5] Implement a read_write_in_place method for in-place transfers --- src/spidevioctl.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/spidevioctl.rs b/src/spidevioctl.rs index 1a236505c..7e41ab215 100644 --- a/src/spidevioctl.rs +++ b/src/spidevioctl.rs @@ -108,6 +108,19 @@ impl<'a, 'b> spi_ioc_transfer<'a, 'b> { } } + /// Create a read/write transfer using the same buffer for reading + /// and writing (in-place transfer). + pub fn read_write_in_place(buf: &'a mut [u8]) -> Self { + // This is allowed according to a comment in the linux source tree: + // https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/include/linux/spi/spi.h?id=211ddde0823f1442e4ad052a2f30f050145ccada#n1073 + spi_ioc_transfer { + rx_buf: buf.as_ptr() as *const () as usize as u64, + tx_buf: buf.as_ptr() as *const () as usize as u64, + len: buf.len() as u32, + ..Default::default() + } + } + /// Create a delay transfer of a number of microseconds pub fn delay(microseconds: u16) -> Self { spi_ioc_transfer { From e0969a466c664716779cea1854892f5d3e057476 Mon Sep 17 00:00:00 2001 From: Jan Niehusmann Date: Wed, 22 Oct 2025 11:18:25 +0000 Subject: [PATCH 2/5] Use a better reference allowing to share rx/tx buffers --- src/spidevioctl.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spidevioctl.rs b/src/spidevioctl.rs index 7e41ab215..c6ed322af 100644 --- a/src/spidevioctl.rs +++ b/src/spidevioctl.rs @@ -112,7 +112,7 @@ impl<'a, 'b> spi_ioc_transfer<'a, 'b> { /// and writing (in-place transfer). pub fn read_write_in_place(buf: &'a mut [u8]) -> Self { // This is allowed according to a comment in the linux source tree: - // https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/include/linux/spi/spi.h?id=211ddde0823f1442e4ad052a2f30f050145ccada#n1073 + // https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/Documentation/spi/spidev.rst?id=211ddde0823f1442e4ad052a2f30f050145ccada#n191 spi_ioc_transfer { rx_buf: buf.as_ptr() as *const () as usize as u64, tx_buf: buf.as_ptr() as *const () as usize as u64, From 0c0531c8c3424054d501a2ac6b4605b9677c79f9 Mon Sep 17 00:00:00 2001 From: Christian Meusel Date: Thu, 23 Oct 2025 12:01:23 +0200 Subject: [PATCH 3/5] Add changelog entry --- CHANGELOG.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d85a8fd3..3a8f1a52a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,17 @@ ## Not yet released -[Full Changelog](https://github.com/rust-embedded/rust-spidev/compare/0.6.0...HEAD) +[Full Changelog](https://github.com/rust-embedded/rust-spidev/compare/0.6.1...HEAD) + +## 0.6.1 / 2025-10-23 + +[Full Changelog](https://github.com/rust-embedded/rust-spidev/compare/0.6.0...0.6.1) + +- Backport `read_write_in_place` from [#49](https://github.com/rust-embedded/rust-spidev/pull/49) + for fixing + [linux-embedded-hal/#120](https://github.com/rust-embedded/linux-embedded-hal/issues/120) + with a patch release + ## 0.6.0 / 2023-08-03 From f556ffcceb18b3ed1e61708a99111f436ae765a3 Mon Sep 17 00:00:00 2001 From: Christian Meusel Date: Thu, 23 Oct 2025 12:03:25 +0200 Subject: [PATCH 4/5] Prepare release 0.6.1 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 89387b480..9144976c0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "spidev" -version = "0.6.0" +version = "0.6.1" authors = [ "Paul Osborne ", "The Embedded Linux Team " From 4c960d20477789d182ae522dcc3032a1780dd1c7 Mon Sep 17 00:00:00 2001 From: Christian Meusel Date: Thu, 23 Oct 2025 12:04:21 +0200 Subject: [PATCH 5/5] Bump version for next release cycle --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 9144976c0..0c867849f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "spidev" -version = "0.6.1" +version = "0.6.2-alpha.0" authors = [ "Paul Osborne ", "The Embedded Linux Team "