[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 4/6] qtest: factor out qtest_install_gpio_out_intercepts
From: |
Peter Maydell |
Subject: |
Re: [PATCH 4/6] qtest: factor out qtest_install_gpio_out_intercepts |
Date: |
Mon, 24 Jul 2023 17:18:02 +0100 |
On Sat, 15 Jul 2023 at 00:27, Chris Laplante <chris@laplante.io> wrote:
>
> 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);
> }
I think you should put this patch before patch 2 -- create the
new function first, and then you can directly use it,
rather than first creating the duplicate code and then
getting rid of it.
thanks
-- PMM
- [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, 2023/07/14
- Re: [PATCH 4/6] qtest: factor out qtest_install_gpio_out_intercepts,
Peter Maydell <=
- [PATCH 6/6] qtest: microbit-test: add tests for nRF51 DETECT, Chris Laplante, 2023/07/14
- [PATCH 5/6] qtest: irq_intercept_[out/in]: return FAIL if no intercepts are installed, Chris Laplante, 2023/07/14
- Re: [PATCH 0/6] Add nRF51 DETECT signal with test, Peter Maydell, 2023/07/24