rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rahul Rameshbabu <sergeantsagara@protonmail.com>
To: rust-for-linux@vger.kernel.org
Cc: linux-input@vger.kernel.org, Jiri Kosina <jikos@kernel.org>,
	a.hindborg@kernel.org, alex.gaynor@gmail.com,
	aliceryhl@google.com, benno.lossin@proton.me,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	bjorn3_gh@protonmail.com, boqun.feng@gmail.com, dakr@kernel.org,
	db48x@db48x.net, gary@garyguo.net, ojeda@kernel.org,
	tmgross@umich.edu, peter.hutterer@who-t.net
Subject: Re: [PATCH v2 2/4] rust: add kref bindings
Date: Sun, 20 Jul 2025 16:02:09 +0000	[thread overview]
Message-ID: <87tt36sveu.fsf@protonmail.com> (raw)
In-Reply-To: <20250713211012.101476-8-sergeantsagara@protonmail.com>

On Sun, 13 Jul, 2025 21:12:06 +0000 "Rahul Rameshbabu" <sergeantsagara@protonmail.com> wrote:
> Introduce kref bindings for use in the Rust HID abstractions. Needed for
> implementing the AlwaysRefCounted trait for kernel::hid::Device. Add rust
> helpers for binding the kref_get and kref_put static inline C functions.
>
> Signed-off-by: Rahul Rameshbabu <sergeantsagara@protonmail.com>
> ---
>  rust/bindings/bindings_helper.h |  1 +
>  rust/helpers/helpers.c          |  1 +
>  rust/helpers/kref.c             | 13 +++++++++++++
>  3 files changed, 15 insertions(+)
>  create mode 100644 rust/helpers/kref.c
>
> diff --git a/rust/bindings/bindings_helper.h b/rust/bindings/bindings_helper.h
> index 8cbb660e2ec2..41a98d5b6521 100644
> --- a/rust/bindings/bindings_helper.h
> +++ b/rust/bindings/bindings_helper.h
> @@ -54,6 +54,7 @@
>  #include <linux/fs.h>
>  #include <linux/jiffies.h>
>  #include <linux/jump_label.h>
> +#include <linux/kref.h>
>  #include <linux/mdio.h>
>  #include <linux/miscdevice.h>
>  #include <linux/of_device.h>
> diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c
> index b15b3cddad4e..7f5403d6c51c 100644
> --- a/rust/helpers/helpers.c
> +++ b/rust/helpers/helpers.c
> @@ -25,6 +25,7 @@
>  #include "fs.c"
>  #include "io.c"
>  #include "jump_label.c"
> +#include "kref.c"
>  #include "kunit.c"
>  #include "mm.c"
>  #include "mutex.c"
> diff --git a/rust/helpers/kref.c b/rust/helpers/kref.c
> new file mode 100644
> index 000000000000..25eeb0a724ac
> --- /dev/null
> +++ b/rust/helpers/kref.c
> @@ -0,0 +1,13 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +#include <linux/kref.h>
> +
> +void rust_helper_kref_get(struct kref *kref)
> +{
> +	kref_get(kref);
> +}
> +
> +void rust_helper_kref_put(struct kref *kref, void (*release)(struct kref *kref))
> +{
> +	kref_put(kref, release);
> +}

I am about to send out my v3, and this patch will no longer be needed.
Would it make sense to send this out separately? I can also just keep it
stashed away till someone needs it.

Thanks,
Rahul Rameshbabu


  reply	other threads:[~2025-07-20 16:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-13 21:11 [PATCH v2 0/4] Initial work for Rust abstraction for HID device driver development Rahul Rameshbabu
2025-07-13 21:11 ` [PATCH v2 1/4] HID: core: Change hid_driver to use a const char* for name Rahul Rameshbabu
2025-07-13 21:12 ` [PATCH v2 2/4] rust: add kref bindings Rahul Rameshbabu
2025-07-20 16:02   ` Rahul Rameshbabu [this message]
2025-07-20 16:07     ` Boqun Feng
2025-07-13 21:12 ` [PATCH v2 3/4] rust: core abstractions for HID drivers Rahul Rameshbabu
2025-07-13 21:57   ` Miguel Ojeda
2025-07-20 16:44     ` Rahul Rameshbabu
2025-07-15 15:04   ` Danilo Krummrich
2025-07-19 22:46     ` Rahul Rameshbabu
2025-07-13 21:12 ` [PATCH v2 4/4] rust: hid: Glorious Gaming PC Race Model O and O- mice reference driver Rahul Rameshbabu
2025-07-13 21:46   ` Miguel Ojeda

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=87tt36sveu.fsf@protonmail.com \
    --to=sergeantsagara@protonmail.com \
    --cc=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=db48x@db48x.net \
    --cc=gary@garyguo.net \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=peter.hutterer@who-t.net \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    /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).