linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Erik Schilling <erik.schilling@linaro.org>
To: Linux-GPIO <linux-gpio@vger.kernel.org>
Cc: Viresh Kumar <viresh.kumar@linaro.org>,
	Erik Schilling <erik.schilling@linaro.org>
Subject: [libgpiod][PATCH 1/2] bindings: rust: construct chip infos by reference
Date: Wed, 27 Sep 2023 11:25:23 +0200	[thread overview]
Message-ID: <20230927-chip-drop-arc-v1-1-28013bf95948@linaro.org> (raw)
In-Reply-To: <20230927-chip-drop-arc-v1-0-28013bf95948@linaro.org>

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>
---
 bindings/rust/libgpiod/src/chip.rs | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/bindings/rust/libgpiod/src/chip.rs b/bindings/rust/libgpiod/src/chip.rs
index 81e1be6..4545ddb 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,

-- 
2.41.0


  reply	other threads:[~2023-09-27  9:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-27  9:25 [libgpiod][PATCH 0/2] rust: bindings: drop unneeded Arc within Chip Erik Schilling
2023-09-27  9:25 ` Erik Schilling [this message]
2023-09-27  9:25 ` [libgpiod][PATCH 2/2] bindings: rust: " Erik Schilling
2023-09-27  9:31 ` [libgpiod][PATCH 0/2] rust: bindings: " Erik Schilling
2023-09-28  8:58 ` Viresh Kumar
2023-09-29 12:41 ` Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230927-chip-drop-arc-v1-1-28013bf95948@linaro.org \
    --to=erik.schilling@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).