diff options
author | Erik Schilling <erik.schilling@linaro.org> | 2023-09-27 11:25:23 +0200 |
---|---|---|
committer | Bartosz Golaszewski <bartosz.golaszewski@linaro.org> | 2023-09-29 14:45:55 +0200 |
commit | a97fe9654287da050d5ac1cdeab825e845f4c7bb (patch) | |
tree | efd34dfe505e45e944208b8664994dd1cea886d6 | |
parent | 27afa47fcbb5905ada95e1e7b8ab9faba9ba9c0c (diff) | |
download | libgpiod-a97fe9654287da050d5ac1cdeab825e845f4c7bb.tar.gz |
bindings: rust: construct chip infos by reference
No need to clone the Arc for this. A simple reference is enough to get
to the underlying chip pointer.
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
-rw-r--r-- | bindings/rust/libgpiod/src/chip.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/bindings/rust/libgpiod/src/chip.rs b/bindings/rust/libgpiod/src/chip.rs index 81e1be6b..4545ddbe 100644 --- a/bindings/rust/libgpiod/src/chip.rs +++ b/bindings/rust/libgpiod/src/chip.rs @@ -79,7 +79,7 @@ impl Chip { /// Get the chip name as represented in the kernel. pub fn info(&self) -> Result<Info> { - Info::new(self.ichip.clone()) + Info::new(self) } /// Get the path used to find the chip. @@ -239,9 +239,9 @@ pub struct Info { impl Info { /// Find a GPIO chip by path. - fn new(chip: Arc<Internal>) -> Result<Self> { - // SAFETY: `gpiod_chip` is guaranteed to be valid here. - let info = unsafe { gpiod::gpiod_chip_get_info(chip.chip) }; + fn new(chip: &Chip) -> Result<Self> { + // SAFETY: `chip.ichip.chip` is guaranteed to be valid here. + let info = unsafe { gpiod::gpiod_chip_get_info(chip.ichip.chip) }; if info.is_null() { return Err(Error::OperationFailed( OperationType::ChipGetInfo, |