[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/6] qtest: factor out qtest_install_gpio_out_intercepts
From: |
Chris Laplante |
Subject: |
[PATCH 4/6] qtest: factor out qtest_install_gpio_out_intercepts |
Date: |
Fri, 14 Jul 2023 23:27:37 +0000 |
Simplify the code a bit.
Signed-off-by: Chris Laplante <chris@laplante.io>
---
softmmu/qtest.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/softmmu/qtest.c b/softmmu/qtest.c
index 74482ce3cd..051bbf4177 100644
--- a/softmmu/qtest.c
+++ b/softmmu/qtest.c
@@ -365,6 +365,15 @@ void qtest_set_command_cb(bool (*pc_cb)(CharBackend *chr,
gchar **words))
process_command_cb = pc_cb;
}
+static void qtest_install_gpio_out_intercepts(DeviceState *dev, const char
*name, int n)
+{
+ qemu_irq *disconnected = g_new0(qemu_irq, 1);
+ qemu_irq icpt = qemu_allocate_irq(qtest_irq_handler,
+ disconnected, n);
+
+ *disconnected = qdev_intercept_gpio_out(dev, icpt,name, n);
+}
+
static void qtest_process_command(CharBackend *chr, gchar **words)
{
const gchar *command;
@@ -421,23 +430,13 @@ static void qtest_process_command(CharBackend *chr, gchar
**words)
if (is_outbound) {
if (is_named) {
if (ngl->name && strcmp(ngl->name, words[2]) == 0) {
- qemu_irq *disconnected = g_new0(qemu_irq, 1);
- qemu_irq icpt = qemu_allocate_irq(qtest_irq_handler,
- disconnected, 0);
-
- *disconnected = qdev_intercept_gpio_out(dev, icpt,
- ngl->name, 0);
+ qtest_install_gpio_out_intercepts(dev, ngl->name, 0);
break;
}
} else if (!ngl->name) {
int i;
for (i = 0; i < ngl->num_out; ++i) {
- qemu_irq *disconnected = g_new0(qemu_irq, 1);
- qemu_irq icpt = qemu_allocate_irq(qtest_irq_handler,
- disconnected, i);
-
- *disconnected = qdev_intercept_gpio_out(dev, icpt,
- ngl->name, i);
+ qtest_install_gpio_out_intercepts(dev, ngl->name, i);
}
}
} else {
--
2.39.2
- [PATCH 0/6] Add nRF51 DETECT signal with test, Chris Laplante, 2023/07/14
- [PATCH 1/6] hw/gpio/nrf51: implement DETECT signal, Chris Laplante, 2023/07/14
- [PATCH 2/6] qtest: implement named interception of out-GPIO, Chris Laplante, 2023/07/14
- [PATCH 3/6] qtest: bail from irq_intercept_in if name is specified, Chris Laplante, 2023/07/14
- [PATCH 4/6] qtest: factor out qtest_install_gpio_out_intercepts,
Chris Laplante <=
- [PATCH 5/6] qtest: irq_intercept_[out/in]: return FAIL if no intercepts are installed, Chris Laplante, 2023/07/14
- [PATCH 6/6] qtest: microbit-test: add tests for nRF51 DETECT, Chris Laplante, 2023/07/14
- Re: [PATCH 0/6] Add nRF51 DETECT signal with test, Peter Maydell, 2023/07/24