From: Martin Kletzander <mkletzan@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
libvir-list@redhat.com,
"Christian Schoenebeck" <qemu_oss@crudebyte.com>,
"Yanan Wang" <wangyanan55@huawei.com>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
"Qiuhao Li" <Qiuhao.Li@outlook.com>,
"Hervé Poussineau" <hpoussin@reactos.org>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Laurent Vivier" <lvivier@redhat.com>,
"Thomas Huth" <thuth@redhat.com>,
"Alistair Francis" <alistair@alistair23.me>,
"Alexander Bulekov" <alxndr@bu.edu>,
"Bandan Das" <bsd@redhat.com>,
qemu-arm@nongnu.org, "Jan Kiszka" <jan.kiszka@web.de>,
"Pavel Dovgalyuk" <pavel.dovgaluk@ispras.ru>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Darren Kenny" <darren.kenny@oracle.com>,
"Thomas Huth" <huth@tuxfamily.org>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
qemu-ppc@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>
Subject: [PATCH 02/18] hw/input/tsc210x: Extract common init code into new function
Date: Mon, 25 Apr 2022 10:21:45 +0200 [thread overview]
Message-ID: <1d75877cf4cc2a38f87633ff16f9fea3e1bb0c03.1650874791.git.mkletzan@redhat.com> (raw)
In-Reply-To: <cover.1650874791.git.mkletzan@redhat.com>
This deduplicates several lines and will make future changes more
concise.
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
---
hw/input/tsc210x.c | 68 ++++++++++++++++------------------------------
1 file changed, 24 insertions(+), 44 deletions(-)
diff --git a/hw/input/tsc210x.c b/hw/input/tsc210x.c
index df7313db5d7f..f16a8090b7c7 100644
--- a/hw/input/tsc210x.c
+++ b/hw/input/tsc210x.c
@@ -31,6 +31,7 @@
#include "hw/input/tsc2xxx.h"
#include "hw/irq.h"
#include "migration/vmstate.h"
+#include "qapi/error.h"
#define TSC_DATA_REGISTERS_PAGE 0x0
#define TSC_CONTROL_REGISTERS_PAGE 0x1
@@ -1070,20 +1071,10 @@ static const VMStateDescription vmstate_tsc2301 = {
.fields = vmstatefields_tsc210x,
};
-uWireSlave *tsc2102_init(qemu_irq pint)
+static void tsc210x_init(TSC210xState *s,
+ const char *name,
+ const VMStateDescription *vmsd)
{
- TSC210xState *s;
-
- s = g_new0(TSC210xState, 1);
- s->x = 160;
- s->y = 160;
- s->pressure = 0;
- s->precision = s->nextprecision = 0;
- s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, tsc210x_timer_tick, s);
- s->pint = pint;
- s->model = 0x2102;
- s->name = "tsc2102";
-
s->tr[0] = 0;
s->tr[1] = 1;
s->tr[2] = 1;
@@ -1105,13 +1096,29 @@ uWireSlave *tsc2102_init(qemu_irq pint)
tsc210x_reset(s);
- qemu_add_mouse_event_handler(tsc210x_touchscreen_event, s, 1,
- "QEMU TSC2102-driven Touchscreen");
+ qemu_add_mouse_event_handler(tsc210x_touchscreen_event, s, 1, name);
AUD_register_card(s->name, &s->card);
qemu_register_reset((void *) tsc210x_reset, s);
- vmstate_register(NULL, 0, &vmstate_tsc2102, s);
+ vmstate_register(NULL, 0, vmsd, s);
+}
+
+uWireSlave *tsc2102_init(qemu_irq pint)
+{
+ TSC210xState *s;
+
+ s = g_new0(TSC210xState, 1);
+ s->x = 160;
+ s->y = 160;
+ s->pressure = 0;
+ s->precision = s->nextprecision = 0;
+ s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, tsc210x_timer_tick, s);
+ s->pint = pint;
+ s->model = 0x2102;
+ s->name = "tsc2102";
+
+ tsc210x_init(s, "QEMU TSC2102-driven Touchscreen", &vmstate_tsc2102);
return &s->chip;
}
@@ -1132,34 +1139,7 @@ uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav)
s->model = 0x2301;
s->name = "tsc2301";
- s->tr[0] = 0;
- s->tr[1] = 1;
- s->tr[2] = 1;
- s->tr[3] = 0;
- s->tr[4] = 1;
- s->tr[5] = 0;
- s->tr[6] = 1;
- s->tr[7] = 0;
-
- s->chip.opaque = s;
- s->chip.send = (void *) tsc210x_write;
- s->chip.receive = (void *) tsc210x_read;
-
- s->codec.opaque = s;
- s->codec.tx_swallow = (void *) tsc210x_i2s_swallow;
- s->codec.set_rate = (void *) tsc210x_i2s_set_rate;
- s->codec.in.fifo = s->in_fifo;
- s->codec.out.fifo = s->out_fifo;
-
- tsc210x_reset(s);
-
- qemu_add_mouse_event_handler(tsc210x_touchscreen_event, s, 1,
- "QEMU TSC2301-driven Touchscreen");
-
- AUD_register_card(s->name, &s->card);
-
- qemu_register_reset((void *) tsc210x_reset, s);
- vmstate_register(NULL, 0, &vmstate_tsc2301, s);
+ tsc210x_init(s, "QEMU TSC2301-driven Touchscreen", &vmstate_tsc2301);
return &s->chip;
}
--
2.35.1
next prev parent reply other threads:[~2022-04-25 8:35 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-25 8:21 [PATCH 00/18] RFC: Remove deprecated audio features Martin Kletzander
2022-04-25 8:21 ` [PATCH 01/18] hw/audio: Remove -soundhw support Martin Kletzander
2022-04-25 13:16 ` Daniel P. Berrangé
2022-04-26 8:53 ` Stefan Hajnoczi
2022-04-27 10:10 ` Paolo Bonzini
2022-04-25 8:21 ` Martin Kletzander [this message]
2022-04-25 13:19 ` [PATCH 02/18] hw/input/tsc210x: Extract common init code into new function Daniel P. Berrangé
2022-04-25 8:21 ` [PATCH 03/18] hw/audio: Simplify hda audio init Martin Kletzander
2022-04-25 13:35 ` Daniel P. Berrangé
2022-04-25 14:06 ` Daniel P. Berrangé
2022-04-25 8:21 ` [PATCH 04/18] hw/audio/lm4549: Add errp error reporting to init function Martin Kletzander
2022-04-25 14:08 ` Daniel P. Berrangé
2022-04-25 8:21 ` [PATCH 05/18] tests/qtest: Specify audiodev= and -audiodev Martin Kletzander
2022-04-25 13:42 ` Daniel P. Berrangé
2022-04-29 10:37 ` Martin Kletzander
2022-04-25 8:21 ` [PATCH 06/18] ui/vnc: Require audiodev= Martin Kletzander
2022-04-25 13:48 ` Daniel P. Berrangé
2022-04-27 9:32 ` Paolo Bonzini
2022-04-27 9:41 ` Daniel P. Berrangé
2022-04-25 8:21 ` [PATCH 07/18] Introduce machine's default-audiodev property Martin Kletzander
2022-04-25 14:06 ` Daniel P. Berrangé
2022-04-29 11:36 ` Martin Kletzander
2022-04-25 8:21 ` [PATCH 08/18] audio: Add easy dummy audio initialiser Martin Kletzander
2022-04-25 8:21 ` [PATCH 09/18] hw/display/xlnx_dp.c: Add audiodev property Martin Kletzander
2022-04-25 8:21 ` [PATCH 10/18] hw/input/tsc210x.c: Support machine-default audiodev with fallback Martin Kletzander
2022-04-25 8:21 ` [PATCH 11/18] hw/arm: " Martin Kletzander
2022-04-25 8:21 ` [PATCH 12/18] hw/ppc: " Martin Kletzander
2022-04-25 8:21 ` [PATCH 13/18] audio: Make AUD_register_card fallible and require audiodev= Martin Kletzander
2022-04-25 13:34 ` Daniel P. Berrangé
2022-04-25 13:39 ` Daniel P. Berrangé
2022-04-25 8:21 ` [PATCH 14/18] audio: Require AudioState in AUD_add_capture Martin Kletzander
2022-04-25 14:11 ` Daniel P. Berrangé
2022-04-25 8:21 ` [PATCH 15/18] audio: Be more strict during audio backend initialisation Martin Kletzander
2022-04-25 14:16 ` Daniel P. Berrangé
2022-04-25 8:21 ` [PATCH 16/18] audio: Remove legacy audio environment variables and options Martin Kletzander
2022-04-25 14:19 ` Daniel P. Berrangé
2022-04-25 8:22 ` [PATCH 17/18] audio: Remove unused can_be_default Martin Kletzander
2022-04-25 14:19 ` Daniel P. Berrangé
2022-04-25 8:22 ` [PATCH 18/18] audio/spiceaudio: Fail initialisation when not using spice Martin Kletzander
2022-04-25 13:08 ` Daniel P. Berrangé
2022-04-25 17:05 ` [PATCH 00/18] RFC: Remove deprecated audio features Mark Cave-Ayland
2022-04-29 12:04 ` Martin Kletzander
2022-04-26 8:54 ` Stefan Hajnoczi
2023-09-15 11:47 ` Paolo Bonzini
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=1d75877cf4cc2a38f87633ff16f9fea3e1bb0c03.1650874791.git.mkletzan@redhat.com \
--to=mkletzan@redhat.com \
--cc=Qiuhao.Li@outlook.com \
--cc=alistair@alistair23.me \
--cc=alxndr@bu.edu \
--cc=berrange@redhat.com \
--cc=bsd@redhat.com \
--cc=darren.kenny@oracle.com \
--cc=edgar.iglesias@gmail.com \
--cc=eduardo@habkost.net \
--cc=f4bug@amsat.org \
--cc=hpoussin@reactos.org \
--cc=huth@tuxfamily.org \
--cc=jan.kiszka@web.de \
--cc=kraxel@redhat.com \
--cc=libvir-list@redhat.com \
--cc=lvivier@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=pavel.dovgaluk@ispras.ru \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu_oss@crudebyte.com \
--cc=stefanha@redhat.com \
--cc=thuth@redhat.com \
--cc=wangyanan55@huawei.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).