From cc5677fd664a0a9d4cb382b0b8be996fcadceaa7 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Fri, 8 Jul 2022 08:18:30 +0200 Subject: [PATCH 1/4] Fix codeowners --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 2f02147ec..3024413f9 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* rust-embedded/embedded-linux +* @rust-embedded/embedded-linux From 9040b0ac905ca918eb889999ca660b3e71457113 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Tue, 4 Mar 2025 12:10:47 +0100 Subject: [PATCH 2/4] Fix clippy warnings --- src/lib.rs | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index a90eb749e..4a258d9ca 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,18 +26,16 @@ //! use std::thread::sleep; //! use std::time::Duration; //! -//! fn main() { -//! let my_led = Pin::new(127); // number depends on chip, etc. -//! my_led.with_exported(|| { -//! my_led.set_direction(Direction::Out).unwrap(); -//! loop { -//! my_led.set_value(0).unwrap(); -//! sleep(Duration::from_millis(200)); -//! my_led.set_value(1).unwrap(); -//! sleep(Duration::from_millis(200)); -//! } -//! }).unwrap(); -//! } +//! let my_led = Pin::new(127); // number depends on chip, etc. +//! my_led.with_exported(|| { +//! my_led.set_direction(Direction::Out).unwrap(); +//! loop { +//! my_led.set_value(0).unwrap(); +//! sleep(Duration::from_millis(200)); +//! my_led.set_value(1).unwrap(); +//! sleep(Duration::from_millis(200)); +//! } +//! }).unwrap(); //! ``` #![cfg_attr(feature = "async-tokio", allow(deprecated))] @@ -247,7 +245,7 @@ impl Pin { /// This function will error out if the kernel does not support the GPIO /// sysfs interface (i.e. `/sys/class/gpio` does not exist). pub fn is_exported(&self) -> bool { - fs::metadata(&format!("/sys/class/gpio/gpio{}", self.pin_num)).is_ok() + fs::metadata(format!("/sys/class/gpio/gpio{}", self.pin_num)).is_ok() } /// Export the GPIO @@ -276,7 +274,7 @@ impl Pin { /// } /// ``` pub fn export(&self) -> Result<()> { - if fs::metadata(&format!("/sys/class/gpio/gpio{}", self.pin_num)).is_err() { + if fs::metadata(format!("/sys/class/gpio/gpio{}", self.pin_num)).is_err() { let mut export_file = File::create("/sys/class/gpio/export")?; export_file.write_all(format!("{}", self.pin_num).as_bytes())?; } @@ -290,7 +288,7 @@ impl Pin { /// exported, it will return without error. That is, whenever /// this function returns Ok, the GPIO is not exported. pub fn unexport(&self) -> Result<()> { - if fs::metadata(&format!("/sys/class/gpio/gpio{}", self.pin_num)).is_ok() { + if fs::metadata(format!("/sys/class/gpio/gpio{}", self.pin_num)).is_ok() { let mut unexport_file = File::create("/sys/class/gpio/unexport")?; unexport_file.write_all(format!("{}", self.pin_num).as_bytes())?; } @@ -501,15 +499,15 @@ impl Pin { #[test] fn extract_pin_fom_path_test() { - let tok1 = Pin::extract_pin_from_path(&"/sys/class/gpio/gpio951"); + let tok1 = Pin::extract_pin_from_path("/sys/class/gpio/gpio951"); assert_eq!(951, tok1.unwrap()); - let tok2 = Pin::extract_pin_from_path(&"/sys/CLASS/gpio/gpio951/"); + let tok2 = Pin::extract_pin_from_path("/sys/CLASS/gpio/gpio951/"); assert_eq!(951, tok2.unwrap()); - let tok3 = Pin::extract_pin_from_path(&"../../devices/soc0/gpiochip3/gpio/gpio124"); + let tok3 = Pin::extract_pin_from_path("../../devices/soc0/gpiochip3/gpio/gpio124"); assert_eq!(124, tok3.unwrap()); - let err1 = Pin::extract_pin_from_path(&"/sys/CLASS/gpio/gpio"); + let err1 = Pin::extract_pin_from_path("/sys/CLASS/gpio/gpio"); assert!(err1.is_err()); - let err2 = Pin::extract_pin_from_path(&"/sys/class/gpio/gpioSDS"); + let err2 = Pin::extract_pin_from_path("/sys/class/gpio/gpioSDS"); assert!(err2.is_err()); } #[cfg(not(target_os = "wasi"))] @@ -532,7 +530,7 @@ impl PinPoller { /// Create a new PinPoller for the provided pin number #[cfg(any(target_os = "linux", target_os = "android"))] pub fn new(pin_num: u64) -> Result { - let devfile: File = File::open(&format!("/sys/class/gpio/gpio{}/value", pin_num))?; + let devfile: File = File::open(format!("/sys/class/gpio/gpio{}/value", pin_num))?; let devfile_fd = devfile.as_raw_fd(); let epoll_fd = epoll_create()?; let mut event = EpollEvent::new(EpollFlags::EPOLLPRI | EpollFlags::EPOLLET, 0u64); @@ -609,7 +607,7 @@ pub struct AsyncPinPoller { #[cfg(feature = "mio-evented")] impl AsyncPinPoller { fn new(pin_num: u64) -> Result { - let devfile = File::open(&format!("/sys/class/gpio/gpio{}/value", pin_num))?; + let devfile = File::open(format!("/sys/class/gpio/gpio{}/value", pin_num))?; Ok(AsyncPinPoller { devfile }) } } From 104bce5c2d4323565114223e1a42aca964e1e901 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Tue, 4 Mar 2025 12:11:17 +0100 Subject: [PATCH 3/4] Update copyright --- LICENSE-MIT | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/LICENSE-MIT b/LICENSE-MIT index 2ca22fdb9..4f591b1a4 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -1,7 +1,7 @@ The MIT License (MIT) Copyright (c) 2015 Paul Osborne -Copyright (c) 2021 The Rust Embedded Linux Team +Copyright (c) 2021-2025 The Rust Embedded Linux Team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,4 +20,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - From 15cb0931d8f54c40aa9d56a802d12710f8fd101e Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Tue, 4 Mar 2025 12:14:32 +0100 Subject: [PATCH 4/4] Update dependencies and raise MSRV --- .github/workflows/ci.yml | 5 ++--- CHANGELOG.md | 4 ++++ Cargo.toml | 6 +++--- README.md | 4 ++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f5621ba54..34db98bef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: include: # MSRV - - rust: 1.65.0 + - rust: 1.70.0 TARGET: x86_64-unknown-linux-gnu # Test nightly but don't fail @@ -109,10 +109,9 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.65.0 + toolchain: 1.70.0 components: clippy - uses: actions-rs/clippy-check@v1 with: token: ${{ secrets.GITHUB_TOKEN }} - diff --git a/CHANGELOG.md b/CHANGELOG.md index 65fa7ff81..0efc4fc74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ ### Changed +- Updated `mio` to version `1`. +- Updated `nix` to version `0.26`. +- Minimum supported Rust version updated to 1.70.0 + ## [0.6.2] - 2024-05-13 - Minimum supported Rust version updated to 1.65.0 diff --git a/Cargo.toml b/Cargo.toml index bc2520ba5..21de77454 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ homepage = "https://github.com/rust-embedded/rust-sysfs-gpio" documentation = "https://docs.rs/sysfs_gpio/" description = "Provides access to GPIOs using the Linux sysfs interface." readme = "README.md" -edition = "2018" +edition = "2021" [features] mio-evented = ["mio"] @@ -19,8 +19,8 @@ async-tokio = ["futures", "tokio", "mio-evented"] [dependencies] futures = { version = "0.3", optional = true } -nix = "0.23" -mio = { version = "0.8", optional = true, features = ["os-ext"]} +nix = "0.26" +mio = { version = "1", optional = true, features = ["os-ext"]} tokio = { version = "1", optional = true, features = ["net"] } [dev-dependencies] diff --git a/README.md b/README.md index 1d1a320d1..8f956868d 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ sysfs_gpio [![Build Status](https://github.com/rust-embedded/rust-sysfs-gpio/workflows/CI/badge.svg)](https://github.com/rust-embedded/rust-sysfs-gpio/actions) [![Version](https://img.shields.io/crates/v/sysfs-gpio.svg)](https://crates.io/crates/sysfs-gpio) -![Minimum Supported Rust Version](https://img.shields.io/badge/rustc-1.65+-blue.svg) +![Minimum Supported Rust Version](https://img.shields.io/badge/rustc-1.70+-blue.svg) [![License](https://img.shields.io/crates/l/sysfs-gpio.svg)](https://github.com/rust-embedded/rust-sysfs-gpio/blob/master/README.md#license) - [API Documentation](https://docs.rs/sysfs_gpio) @@ -85,7 +85,7 @@ The following features are planned for the library: ## Minimum Supported Rust Version (MSRV) -This crate is guaranteed to compile on stable Rust 1.65.0 and up. It *might* +This crate is guaranteed to compile on stable Rust 1.70.0 and up. It *might* compile with older versions but that may change in any new patch release. ## Cross Compiling