All of lore.kernel.org
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: Kent Gibson <warthog618@gmail.com>
Cc: "Bartosz Golaszewski" <brgl@bgdev.pl>,
	"Miguel Ojeda" <miguel.ojeda.sandonis@gmail.com>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Vincent Guittot" <vincent.guittot@linaro.org>,
	linux-gpio@vger.kernel.org,
	"Alex Bennée" <alex.bennee@linaro.org>,
	stratos-dev@op-lists.linaro.org,
	"Gerard Ryan" <g.m0n3y.2503@gmail.com>
Subject: Re: [PATCH V6 3/8] libgpiod: Add rust wrapper crate
Date: Tue, 11 Oct 2022 10:16:46 +0530	[thread overview]
Message-ID: <20221011044646.umilituvdyex3bgm@vireshk-i7> (raw)
In-Reply-To: <20221011043749.ecbcwgxub6zs5s5n@vireshk-i7>

On 11-10-22, 10:07, Viresh Kumar wrote:
> And I am not sure why, as the reference isn't used anymore in this
> case to the event0.

This works though:

diff --git a/bindings/rust/libgpiod/examples/gpiobufferevent.rs b/bindings/rust/libgpiod/examples/gpiobufferevent.rs
index 613a800584e3..e16a1a39b22c 100644
--- a/bindings/rust/libgpiod/examples/gpiobufferevent.rs
+++ b/bindings/rust/libgpiod/examples/gpiobufferevent.rs
@@ -40,10 +40,12 @@ fn main() -> Result<()> {
         let event1 = buffer.event(1)?;

         println!("{:?}", (event0.line_offset(), event1.line_offset()));
+        let event0_copy = edge::Event::event_clone(&event0)?;
         drop(event0);
         // This fails to compile
         // request.read_edge_events(&mut buffer)?;
         drop(event1);
         request.read_edge_events(&mut buffer)?;
+        drop(event0_copy);
     }
 }
diff --git a/bindings/rust/libgpiod/src/edge_event.rs b/bindings/rust/libgpiod/src/edge_event.rs
index f5426459d779..12c0fd73f778 100644
--- a/bindings/rust/libgpiod/src/edge_event.rs
+++ b/bindings/rust/libgpiod/src/edge_event.rs
@@ -43,8 +43,8 @@ impl<'b> Event<'b> {
         })
     }

-    pub fn event_clone(&self) -> Result<Self> {
-        let event = unsafe { gpiod::gpiod_edge_event_copy(self.event) };
+    pub fn event_clone(event: &Event) -> Result<Self> {
+        let event = unsafe { gpiod::gpiod_edge_event_copy(event.event) };
         if event.is_null() {
             return Err(Error::OperationFailed(
                 OperationType::EdgeEventCopy,


-- 
viresh

  reply	other threads:[~2022-10-11  4:46 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-26 11:08 [PATCH V6 0/8] libgpiod: Add Rust bindings Viresh Kumar
2022-09-26 11:08 ` [PATCH V6 1/8] libgpiod: Add libgpiod-sys rust crate Viresh Kumar
2022-09-26 11:08 ` [PATCH V6 2/8] libgpiod-sys: Add pre generated rust bindings Viresh Kumar
2022-09-26 11:08 ` [PATCH V6 3/8] libgpiod: Add rust wrapper crate Viresh Kumar
2022-09-26 13:29   ` Bartosz Golaszewski
2022-09-26 15:26     ` Viresh Kumar
2022-09-27 13:18       ` Bartosz Golaszewski
2022-09-27 13:57         ` Viresh Kumar
2022-09-27 15:25           ` Bartosz Golaszewski
2022-09-28 11:10             ` Viresh Kumar
2022-09-28 12:20               ` Bartosz Golaszewski
2022-09-28 15:17                 ` Viresh Kumar
2022-09-28 17:54                   ` Bartosz Golaszewski
2022-09-29  6:54                     ` Viresh Kumar
2022-09-29  7:37                       ` Bartosz Golaszewski
2022-09-29  8:58                         ` Viresh Kumar
2022-09-29 11:16                           ` Bartosz Golaszewski
2022-09-29 11:43                         ` Kent Gibson
2022-09-29 13:55                     ` Miguel Ojeda
2022-10-11  4:16                       ` Viresh Kumar
2022-10-11  4:25                         ` Kent Gibson
2022-10-11  4:37                           ` Viresh Kumar
2022-10-11  4:46                             ` Viresh Kumar [this message]
2022-10-13  6:12                         ` Viresh Kumar
2022-10-14  9:45                           ` Bartosz Golaszewski
2022-10-14  9:57                             ` Viresh Kumar
2022-10-14 14:25                               ` Bartosz Golaszewski
2022-10-14 16:06                                 ` Kent Gibson
2022-10-17 11:26                                   ` Viresh Kumar
2022-10-17 11:34                                     ` Kent Gibson
2022-10-17 11:37                                       ` Viresh Kumar
2022-09-26 11:08 ` [PATCH V6 4/8] libgpiod: Add rust examples Viresh Kumar
2022-09-26 11:08 ` [PATCH V6 5/8] libgpiod: Add gpiosim rust crate Viresh Kumar
2022-09-26 11:08 ` [PATCH V6 6/8] gpiosim: Add pre generated rust bindings Viresh Kumar
2022-09-26 11:08 ` [PATCH V6 7/8] libgpiod: Add rust tests Viresh Kumar
2022-09-26 11:08 ` [PATCH V6 8/8] libgpiod: Integrate building of rust bindings with make Viresh Kumar
2022-09-26 15:57 ` [PATCH V6 0/8] libgpiod: Add Rust bindings Viresh Kumar

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=20221011044646.umilituvdyex3bgm@vireshk-i7 \
    --to=viresh.kumar@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=g.m0n3y.2503@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=stratos-dev@op-lists.linaro.org \
    --cc=vincent.guittot@linaro.org \
    --cc=warthog618@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.