1
0
mirror of https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git synced 2026-10-24 00:48:53 +03:00

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>
This commit is contained in:
Erik Schilling
2023-09-27 11:25:23 +02:00
committed by Bartosz Golaszewski
parent 27afa47fcb
commit a97fe96542

View File

@@ -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,