From: "Chen Miao" <chenmiao@openatom.club>
To: "Paolo Bonzini" <pbonzini@redhat.com>
Cc: <zhao1.liu@intel.com>, <manos.pitsidianakis@linaro.org>,
<richard.henderson@linaro.org>, <philmd@linaro.org>,
<chao.liu@openatom.club>, <qemu-rust@nongnu.org>,
<qemu-devel@nongnu.org>,
<hust-os-kernel-patches@googlegroups.com>
Subject: Re: [RFC PATCH v2 4/5] rust/hw/core: Provide some interfaces for the GPIO device
Date: Tue, 28 Oct 2025 19:23:46 +0800 [thread overview]
Message-ID: <f8ec1dad-2654-4db8-b994-0ecd2a1943e9@openatom.club> (raw)
In-Reply-To: <CABgObfbeka+fKixBH8F_Fkprvk8oi+dTss21Vn5kYgm4sY0A8g@mail.gmail.com>
On 10/28/2025 6:49 PM, Paolo Bonzini wrote:
> On Tue, Oct 28, 2025 at 11:18 AM chenmiao <chenmiao@openatom.club> wrote:
>> In irq.rs, we added a new get method for the InterruptSource type to determine
>> whether an InterruptSource is null. This eliminates the need to repeatedly
>> call self.cell.get().is_null() for null checks during comparisons.
>> Additionally, we exposed the slice_as_ptrmethod to support external usage with
>> the &[InterruptSource]type.
>>
>> In qdev.rs, we implemented the init_gpio_out_namedfunction, which corresponds
>> to the C function qdev_init_gpio_out_named. We also refactored the
>> init_gpio_outfunction to reuse the init_gpio_out_namedinterface.
>>
>> Signed-off-by: chenmiao <chenmiao@openatom.club>
>> ---
>> rust/hw/core/src/irq.rs | 6 +++++-
>> rust/hw/core/src/qdev.rs | 12 +++++++++---
>> 2 files changed, 14 insertions(+), 4 deletions(-)
>>
>> diff --git a/rust/hw/core/src/irq.rs b/rust/hw/core/src/irq.rs
>> index e0d7784d97..dd5d0cadbc 100644
>> --- a/rust/hw/core/src/irq.rs
>> +++ b/rust/hw/core/src/irq.rs
>> @@ -71,6 +71,10 @@ pub fn pulse(&self) {
>> pub fn raise(&self) {
>> self.set(true);
>> }
>> +
>> + pub fn get(&self) -> bool {
>> + !self.cell.get().is_null()
>> + }
> This should not be get(), but "is_connected()". Also it should be
> implemented for any T, therefore in the "impl<T> InterruptSource<T>"
> block below.
I'll fix it later.
>> }
>>
>> impl<T> InterruptSource<T>
>> @@ -91,7 +95,7 @@ pub(crate) const fn as_ptr(&self) -> *mut *mut bindings::IRQState {
>> self.cell.as_ptr()
>> }
>>
>> - pub(crate) const fn slice_as_ptr(slice: &[Self]) -> *mut *mut bindings::IRQState {
>> + pub const fn slice_as_ptr(slice: &[Self]) -> *mut *mut bindings::IRQState {
>> assert!(!slice.is_empty());
>> slice[0].as_ptr()
>> }
> Since you are not using this, you don't need to expose it outside the crate.
>
> Paolo
I have used this function in the next patch.
Chen Miao
next prev parent reply other threads:[~2025-10-28 11:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-28 10:18 [RFC PATCH v2 4/5] rust/hw/core: Provide some interfaces for the GPIO device chenmiao
2025-10-28 10:49 ` Paolo Bonzini
2025-10-28 11:23 ` Chen Miao [this message]
2025-10-28 11:30 ` Paolo Bonzini
2025-10-28 11:38 ` Chen Miao
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=f8ec1dad-2654-4db8-b994-0ecd2a1943e9@openatom.club \
--to=chenmiao@openatom.club \
--cc=chao.liu@openatom.club \
--cc=hust-os-kernel-patches@googlegroups.com \
--cc=manos.pitsidianakis@linaro.org \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-rust@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=zhao1.liu@intel.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 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).