[PATCH V4 6/8] libgpiod: Derive debug traits for few definitions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



These are required for tests, which will be added by a later commit.

Signed-off-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
---
 bindings/rust/src/chip.rs      | 5 +++++
 bindings/rust/src/chip_info.rs | 1 +
 bindings/rust/src/lib.rs       | 8 +++++++-
 bindings/rust/src/line_info.rs | 1 +
 4 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/bindings/rust/src/chip.rs b/bindings/rust/src/chip.rs
index 50b5d6102f96..ecff4b003cd9 100644
--- a/bindings/rust/src/chip.rs
+++ b/bindings/rust/src/chip.rs
@@ -21,6 +21,7 @@ use super::{
 /// character device. It exposes basic information about the chip and allows
 /// callers to retrieve information about each line, watch lines for state
 /// changes and make line requests.
+#[derive(Debug)]
 pub(crate) struct ChipInternal {
     chip: *mut bindings::gpiod_chip,
 }
@@ -52,11 +53,15 @@ impl Drop for ChipInternal {
     }
 }
 
+#[derive(Debug)]
 pub struct Chip {
     ichip: Arc<ChipInternal>,
     info: ChipInfo,
 }
 
+unsafe impl Send for Chip {}
+unsafe impl Sync for Chip {}
+
 impl Chip {
     /// Find a chip by path.
     pub fn open(path: &str) -> Result<Self> {
diff --git a/bindings/rust/src/chip_info.rs b/bindings/rust/src/chip_info.rs
index 950368b54c6f..7188f91a92a6 100644
--- a/bindings/rust/src/chip_info.rs
+++ b/bindings/rust/src/chip_info.rs
@@ -11,6 +11,7 @@ use vmm_sys_util::errno::Error as IoError;
 use super::{bindings, ChipInternal, Error, Result};
 
 /// GPIO chip Information
+#[derive(Debug)]
 pub struct ChipInfo {
     info: *mut bindings::gpiod_chip_info,
 }
diff --git a/bindings/rust/src/lib.rs b/bindings/rust/src/lib.rs
index 2f2ac515d353..63b0b82281b7 100644
--- a/bindings/rust/src/lib.rs
+++ b/bindings/rust/src/lib.rs
@@ -59,6 +59,7 @@ pub enum Error {
 }
 
 /// Direction settings.
+#[derive(Debug, PartialEq)]
 pub enum Direction {
     /// Request the line(s), but don't change direction.
     AsIs,
@@ -88,6 +89,7 @@ impl Direction {
 }
 
 /// Internal bias settings.
+#[derive(Debug, PartialEq)]
 pub enum Bias {
     /// Don't change the bias setting when applying line config.
     AsIs,
@@ -125,6 +127,7 @@ impl Bias {
 }
 
 /// Drive settings.
+#[derive(Debug, PartialEq)]
 pub enum Drive {
     /// Drive setting is push-pull.
     PushPull,
@@ -154,6 +157,7 @@ impl Drive {
 }
 
 /// Edge detection settings.
+#[derive(Debug, PartialEq)]
 pub enum Edge {
     /// Line edge detection is disabled.
     None,
@@ -223,6 +227,7 @@ impl Config {
 }
 
 /// Event clock settings.
+#[derive(Debug, PartialEq)]
 pub enum EventClock {
     /// Line uses the monotonic clock for edge event timestamps.
     Monotonic,
@@ -248,6 +253,7 @@ impl EventClock {
 }
 
 /// Line status change event types.
+#[derive(Debug, PartialEq)]
 pub enum Event {
     /// Line has been requested.
     LineRequested,
@@ -268,7 +274,7 @@ impl Event {
     }
 }
 
-#[derive(Copy, Clone)]
+#[derive(Copy, Clone, Debug, PartialEq)]
 /// Edge event types.
 pub enum LineEdgeEvent {
     /// Rising edge event.
diff --git a/bindings/rust/src/line_info.rs b/bindings/rust/src/line_info.rs
index 70b6bd6a84bb..426bd16aa616 100644
--- a/bindings/rust/src/line_info.rs
+++ b/bindings/rust/src/line_info.rs
@@ -23,6 +23,7 @@ use super::{
 /// line, which does not include the line value.  The line must be requested
 /// to access the line value.
 
+#[derive(Debug)]
 pub struct LineInfo {
     info: *mut bindings::gpiod_line_info,
     ichip: Option<Arc<ChipInternal>>,
-- 
2.31.1.272.g89b43f80a514




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux