From: "Chen Miao" <chenmiao@openatom.club>
To: <zhao1.liu@intel.com>, <pbonzini@redhat.com>,
<manos.pitsidianakis@linaro.org>, <richard.henderson@linaro.org>,
<philmd@linaro.org>
Cc: <chao.liu@openatom.club>, <dzm91@openatom.club>,
<qemu-rust@nongnu.org>, <qemu-devel@nongnu.org>,
<hust-os-kernel-patches@googlegroups.com>,
"chenmiao" <chenmiao@openatom.club>
Subject: [RFC PATCH V3 3/4] rust/hw/core: Provide some interfaces for the GPIO device
Date: Sat, 29 Nov 2025 14:28:21 +0000 [thread overview]
Message-ID: <69e22b6002d411a8edee3f589c568ce8217c2f37.1764426204.git.chenmiao@openatom.club> (raw)
From: chenmiao <chenmiao@openatom.club>
In qdev.rs, we implemented the init_gpio_out_named function, which corresponds
to the C function qdev_init_gpio_out_named. We also refactored the
init_gpio_out function to reuse the init_gpio_out_named interface.
Signed-off-by: Chen Miao <chenmiao@openatom.club>
---
rust/hw/core/src/qdev.rs | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/rust/hw/core/src/qdev.rs b/rust/hw/core/src/qdev.rs
index c3097a284d..28da94dd0a 100644
--- a/rust/hw/core/src/qdev.rs
+++ b/rust/hw/core/src/qdev.rs
@@ -17,7 +17,7 @@
pub use crate::bindings::{ClockEvent, DeviceClass, Property, ResetType};
use crate::{
- bindings::{self, qdev_init_gpio_in, qdev_init_gpio_out, ResettableClass},
+ bindings::{self, qdev_init_gpio_in, qdev_init_gpio_out_named, ResettableClass},
irq::InterruptSource,
};
@@ -399,11 +399,22 @@ fn do_init_gpio_in(
}
fn init_gpio_out(&self, pins: &[InterruptSource]) {
+ self.init_gpio_out_named(pins, "unnamed-gpio-out", pins.len());
+ }
+
+ fn init_gpio_out_named(&self, pins: &[InterruptSource], name: &str, n: usize) {
+ let c_name = if name.is_empty() {
+ CString::new("unnamed-gpio-out").unwrap()
+ } else {
+ CString::new(name).unwrap()
+ };
+
unsafe {
- qdev_init_gpio_out(
+ qdev_init_gpio_out_named(
self.upcast().as_mut_ptr(),
InterruptSource::slice_as_ptr(pins),
- pins.len() as c_int,
+ c_name.as_ptr(),
+ n as c_int,
);
}
}
--
2.43.0
WARNING: multiple messages have this Message-ID (diff)
From: ChenMiao <chenmiao.ku@gmail.com>
To: zhao1.liu@intel.com, pbonzini@redhat.com,
manos.pitsidianakis@linaro.org, richard.henderson@linaro.org,
philmd@linaro.org
Cc: chao.liu@openatom.club , dzm91@openatom.club ,
qemu-rust@nongnu.org, qemu-devel@nongnu.org,
hust-os-kernel-patches@googlegroups.com,
chenmiao <chenmiao@openatom.club>
Subject: [RESEND RFC PATCH V3 3/4] rust/hw/core: Provide some interfaces for the GPIO device
Date: Sat, 29 Nov 2025 15:43:20 +0000 [thread overview]
Message-ID: <69e22b6002d411a8edee3f589c568ce8217c2f37.1764426204.git.chenmiao@openatom.club> (raw)
Message-ID: <20251129154320.aSM65zgtxbhbecbzkfEgK0G7vAyExKjcLd5p-zRP2yw@z> (raw)
In-Reply-To: <cover.1764426204.git.chenmiao@openatom.club>
From: chenmiao <chenmiao@openatom.club>
In qdev.rs, we implemented the init_gpio_out_named function, which corresponds
to the C function qdev_init_gpio_out_named. We also refactored the
init_gpio_out function to reuse the init_gpio_out_named interface.
Signed-off-by: Chen Miao <chenmiao@openatom.club>
---
rust/hw/core/src/qdev.rs | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/rust/hw/core/src/qdev.rs b/rust/hw/core/src/qdev.rs
index c3097a284d..28da94dd0a 100644
--- a/rust/hw/core/src/qdev.rs
+++ b/rust/hw/core/src/qdev.rs
@@ -17,7 +17,7 @@
pub use crate::bindings::{ClockEvent, DeviceClass, Property, ResetType};
use crate::{
- bindings::{self, qdev_init_gpio_in, qdev_init_gpio_out, ResettableClass},
+ bindings::{self, qdev_init_gpio_in, qdev_init_gpio_out_named, ResettableClass},
irq::InterruptSource,
};
@@ -399,11 +399,22 @@ fn do_init_gpio_in(
}
fn init_gpio_out(&self, pins: &[InterruptSource]) {
+ self.init_gpio_out_named(pins, "unnamed-gpio-out", pins.len());
+ }
+
+ fn init_gpio_out_named(&self, pins: &[InterruptSource], name: &str, n: usize) {
+ let c_name = if name.is_empty() {
+ CString::new("unnamed-gpio-out").unwrap()
+ } else {
+ CString::new(name).unwrap()
+ };
+
unsafe {
- qdev_init_gpio_out(
+ qdev_init_gpio_out_named(
self.upcast().as_mut_ptr(),
InterruptSource::slice_as_ptr(pins),
- pins.len() as c_int,
+ c_name.as_ptr(),
+ n as c_int,
);
}
}
--
2.43.0
next prev reply other threads:[~2025-11-29 14:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-29 14:28 [RFC PATCH V3 0/4] rust/hw: Add the I2C and the first GPIO device Chen Miao
2025-11-29 14:28 ` [RFC PATCH V3 1/4] rust/hw/core: Add the BusState of rust version Chen Miao
2025-11-29 15:43 ` [RESEND RFC " ChenMiao
2025-11-29 14:28 ` [RFC PATCH V3 2/4] rust/hw/core: Add rust bindings/funcs for i2c bus Chen Miao
2025-11-29 15:43 ` [RESEND RFC " ChenMiao
2025-11-29 14:28 ` Chen Miao [this message]
2025-11-29 15:43 ` [RESEND RFC PATCH V3 3/4] rust/hw/core: Provide some interfaces for the GPIO device ChenMiao
2025-11-29 14:28 ` [RFC PATCH V3 4/4] rust/hw/gpio: Add the the first gpio device pcf8574 Chen Miao
2025-11-29 15:43 ` [RESEND RFC " ChenMiao
2025-11-29 15:43 ` [RESEND RFC PATCH V3 0/4] rust/hw: Add the I2C and the first GPIO device ChenMiao
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=69e22b6002d411a8edee3f589c568ce8217c2f37.1764426204.git.chenmiao@openatom.club \
--to=chenmiao@openatom.club \
--cc=chao.liu@openatom.club \
--cc=dzm91@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).