diff mbox series

bindings: rust: expose v2.1 features as flag

Message ID 20231106-rust-bindings-v2_1-v1-1-d90b785a06c0@linaro.org
State New
Headers show
Series bindings: rust: expose v2.1 features as flag | expand

Commit Message

Erik Schilling Nov. 6, 2023, 12:53 p.m. UTC
v2.1 provided a getter to read the chip name from a request.

This adds v2_1 as feature in order to raise the minimum requested version
to v2.1 for exposing the new API.

This is identical to the concept patch that was posted [1] when this
feature flag mechanism was proposed. Only the commit message was
reworded.

[1] https://lore.kernel.org/all/20231006-b4-bindings-old-version-fix-v1-2-a65f431afb97@linaro.org/

Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
---
With v2.1 being released, I am updating feature flags as previously
sketched.

To: Bartosz Golaszewski <brgl@bgdev.pl>
To: Linux-GPIO <linux-gpio@vger.kernel.org>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Cc: Kent Gibson <warthog618@gmail.com>
Cc: Erik Schilling <erik.schilling@linaro.org>
---
 bindings/rust/libgpiod-sys/Cargo.toml        | 9 +++++++--
 bindings/rust/libgpiod/Cargo.toml            | 3 ++-
 bindings/rust/libgpiod/README.md             | 1 +
 bindings/rust/libgpiod/src/line_request.rs   | 4 ++--
 bindings/rust/libgpiod/tests/line_request.rs | 2 +-
 5 files changed, 13 insertions(+), 6 deletions(-)


---
base-commit: 8c8547bfddd58b66c1ed254072bd0cfab2f671b6
change-id: 20231106-rust-bindings-v2_1-a8fa58ae4c0b

Best regards,

Comments

Viresh Kumar Nov. 7, 2023, 6:31 a.m. UTC | #1
On 06-11-23, 13:53, Erik Schilling wrote:
> v2.1 provided a getter to read the chip name from a request.
> 
> This adds v2_1 as feature in order to raise the minimum requested version
> to v2.1 for exposing the new API.
> 
> This is identical to the concept patch that was posted [1] when this
> feature flag mechanism was proposed. Only the commit message was
> reworded.
> 
> [1] https://lore.kernel.org/all/20231006-b4-bindings-old-version-fix-v1-2-a65f431afb97@linaro.org/
> 
> Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
> ---
> With v2.1 being released, I am updating feature flags as previously
> sketched.
> 
> To: Bartosz Golaszewski <brgl@bgdev.pl>
> To: Linux-GPIO <linux-gpio@vger.kernel.org>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Cc: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
> Cc: Kent Gibson <warthog618@gmail.com>
> Cc: Erik Schilling <erik.schilling@linaro.org>
> ---
>  bindings/rust/libgpiod-sys/Cargo.toml        | 9 +++++++--
>  bindings/rust/libgpiod/Cargo.toml            | 3 ++-
>  bindings/rust/libgpiod/README.md             | 1 +
>  bindings/rust/libgpiod/src/line_request.rs   | 4 ++--
>  bindings/rust/libgpiod/tests/line_request.rs | 2 +-
>  5 files changed, 13 insertions(+), 6 deletions(-)

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Bartosz Golaszewski Nov. 8, 2023, 1:06 p.m. UTC | #2
On Mon, Nov 6, 2023 at 1:53 PM Erik Schilling <erik.schilling@linaro.org> wrote:
>
> v2.1 provided a getter to read the chip name from a request.
>
> This adds v2_1 as feature in order to raise the minimum requested version
> to v2.1 for exposing the new API.
>
> This is identical to the concept patch that was posted [1] when this
> feature flag mechanism was proposed. Only the commit message was
> reworded.
>
> [1] https://lore.kernel.org/all/20231006-b4-bindings-old-version-fix-v1-2-a65f431afb97@linaro.org/
>
> Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
> ---

Applied, thanks!

Bart
diff mbox series

Patch

diff --git a/bindings/rust/libgpiod-sys/Cargo.toml b/bindings/rust/libgpiod-sys/Cargo.toml
index b4d26e9..f90615d 100644
--- a/bindings/rust/libgpiod-sys/Cargo.toml
+++ b/bindings/rust/libgpiod-sys/Cargo.toml
@@ -18,11 +18,16 @@  exclude = [
     "Makefile.am",
 ]
 
+[features]
+v2_1 = []
+
 [dependencies]
 
 [build-dependencies]
 bindgen = "0.63"
 system-deps = "2.0"
 
-[package.metadata.system-deps]
-libgpiod = "2"
+[package.metadata.system-deps.libgpiod]
+name = "libgpiod"
+version = "2"
+v2_1 = { version = "2.1" }
diff --git a/bindings/rust/libgpiod/Cargo.toml b/bindings/rust/libgpiod/Cargo.toml
index 3ce05df..7ddf5fd 100644
--- a/bindings/rust/libgpiod/Cargo.toml
+++ b/bindings/rust/libgpiod/Cargo.toml
@@ -19,7 +19,8 @@  exclude = [
 ]
 
 [features]
-vnext = []
+v2_1 = ["libgpiod-sys/v2_1"]
+vnext = ["v2_1"]
 
 [dependencies]
 errno = "0.2.8"
diff --git a/bindings/rust/libgpiod/README.md b/bindings/rust/libgpiod/README.md
index c86b06e..1ef3743 100644
--- a/bindings/rust/libgpiod/README.md
+++ b/bindings/rust/libgpiod/README.md
@@ -28,6 +28,7 @@  C library will be exposed by default.
 Setting flags allows to increase the base version and export features of newer
 versions:
 
+- `v2_1`: Minimum version of `2.1.x`
 - `vnext`: The upcoming, still unreleased version of the C lib
 
 ## License
diff --git a/bindings/rust/libgpiod/src/line_request.rs b/bindings/rust/libgpiod/src/line_request.rs
index a7fe6d0..7ec6508 100644
--- a/bindings/rust/libgpiod/src/line_request.rs
+++ b/bindings/rust/libgpiod/src/line_request.rs
@@ -2,7 +2,7 @@ 
 // SPDX-FileCopyrightText: 2022 Linaro Ltd.
 // SPDX-FileCopyrightText: 2022 Viresh Kumar <viresh.kumar@linaro.org>
 
-#[cfg(feature = "vnext")]
+#[cfg(feature = "v2_1")]
 use std::ffi::CStr;
 use std::os::unix::prelude::AsRawFd;
 use std::time::Duration;
@@ -32,7 +32,7 @@  impl Request {
     }
 
     /// Get the name of the chip this request was made on.
-    #[cfg(feature = "vnext")]
+    #[cfg(feature = "v2_1")]
     pub fn chip_name(&self) -> Result<&str> {
         // SAFETY: The `gpiod_line_request` is guaranteed to be live as long
         // as `&self`
diff --git a/bindings/rust/libgpiod/tests/line_request.rs b/bindings/rust/libgpiod/tests/line_request.rs
index a936a1b..4e095a4 100644
--- a/bindings/rust/libgpiod/tests/line_request.rs
+++ b/bindings/rust/libgpiod/tests/line_request.rs
@@ -60,7 +60,7 @@  mod line_request {
         use super::*;
 
         #[test]
-        #[cfg(feature = "vnext")]
+        #[cfg(feature = "v2_1")]
         fn chip_name() {
             const GPIO: Offset = 2;
             let mut config = TestConfig::new(NGPIO).unwrap();