From nobody Tue Dec 16 07:25:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1650874989; cv=none; d=zohomail.com; s=zohoarc; b=Rz5wMWJFpNkrOd5oqzSe/TzAdNzxemQfeTOZ+2gFjZfsUQLk+8Y6/t+ofUZrjhS+ocyHzJagjKCibsVMs82R668og5WjJO2BDLfGig/N7ceCt6IW8ws5lRq1r2oU26HunKHrNpFnhYVaOc9fesR8VfRnTHsjfoSDNrs8koQDxag= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650874989; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lGr5ZYYCfBjIhbaCs5pjlimDwxXJN466WQPA6PrOrAg=; b=KNF/4kY1YeHd1+/gCglyqStoKqDYRGiCNSqUiSipyVCXuConA2LJLUVN98BGCX1MTk4Qlm5HvZiZJ0zdWfUq3TCFt7xxsA0rL0SsbrO6aMWrdV5qEgQ4bIYqino/u/bPwe78+FZmHxldYe6ZGbKbPEjhq1K/lPJWHtL1xgKSckg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1650874989374736.1756921709533; Mon, 25 Apr 2022 01:23:09 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-135-QGtu_ZRHOJuaFpMGYa8E_A-1; Mon, 25 Apr 2022 04:22:24 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 438551C068CD; Mon, 25 Apr 2022 08:22:17 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 262261468956; Mon, 25 Apr 2022 08:22:17 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6A9541940353; Mon, 25 Apr 2022 08:22:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 164A8194037A for ; Mon, 25 Apr 2022 08:22:09 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 031C3C28117; Mon, 25 Apr 2022 08:22:09 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F38AEC28115 for ; Mon, 25 Apr 2022 08:22:08 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D7C0829AB44F for ; Mon, 25 Apr 2022 08:22:08 +0000 (UTC) Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-197-m-G1qydZOPW7sZSHL-N2rg-1; Mon, 25 Apr 2022 04:22:05 -0400 Received: by mail-wm1-f70.google.com with SMTP id d6-20020a05600c34c600b0039296a2ac7cso6875572wmq.1 for ; Mon, 25 Apr 2022 01:22:04 -0700 (PDT) Received: from wheatley.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id r17-20020a0560001b9100b00207afaa8987sm9545597wru.27.2022.04.25.01.22.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Apr 2022 01:22:02 -0700 (PDT) Received: from wheatley.redhat.com (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id 15F3967B1B57; Mon, 25 Apr 2022 10:22:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650874988; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=lGr5ZYYCfBjIhbaCs5pjlimDwxXJN466WQPA6PrOrAg=; b=MHNov4V2AB4IsA43r6n2CnRFOTh4USoVd40YSSJOV7wyLmY7pYGoxlMn99LRGDve6ZN6vs sD3sAKLRhEHXZ6Hfyt5HrJRx6Bw7tON+SXueQJSYwjg8TXTC8NLQkmNyXwrbqq2VCJdyVK YqChZJLBmYOkDUZQ5zDS6xbrCr37ccg= X-MC-Unique: QGtu_ZRHOJuaFpMGYa8E_A-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: m-G1qydZOPW7sZSHL-N2rg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lGr5ZYYCfBjIhbaCs5pjlimDwxXJN466WQPA6PrOrAg=; b=1shLWOjl1FoELUCHLh59uwZFoU9KKzNeEzrlASigNO9c4b6mqPtni7CeVtOIVMzKgl tCpIluz3+k0+m5A60ssrh/4LUfJq6nHCi9WKxhIGpU9uGPNxRTwS0jEDZ129f18i+T7C nj8t8XbUpa570SxT3bwAB83puzgvXfcarYaIUdKxiTj2YGeTIlpKhZOJ9Q68jfy7a1d+ 3sKQ39SOa8hiqJw3OKhB6M1Hm8N2SekzXsN5VxEkFnXI3p4Ah/Maoo26cQBYsNKCnvB+ MDe/8IDwJWbrNmC3+OaSB1q8P+JUNbhxxyh21tFtQjBS8a5GFXf35dEINZROrg6Zio5h vW4A== X-Gm-Message-State: AOAM5315cat5HuwhN4W6pJty1i5RTb7vriWRnAXQNMDW89U1xzuc4yym h3kOEfHYOHmhXDXHotTO9y5xLpr9Aeq0pVnCxwrweEdipiwJVIekbPfq7NEqys24ySTqSvOaI7Y nUG08s6Gxht0A+Qi2HT0= X-Received: by 2002:a05:600c:1552:b0:38e:c7a4:f056 with SMTP id f18-20020a05600c155200b0038ec7a4f056mr24931328wmg.183.1650874923824; Mon, 25 Apr 2022 01:22:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcPaXQaRYsRK7kFr7dw0OP7er2x/iw/gGtxg/5rbUQrr/TshLfhpO+Mel3UMnOji0xaPOGxg== X-Received: by 2002:a05:600c:1552:b0:38e:c7a4:f056 with SMTP id f18-20020a05600c155200b0038ec7a4f056mr24931297wmg.183.1650874923619; Mon, 25 Apr 2022 01:22:03 -0700 (PDT) From: Martin Kletzander To: qemu-devel@nongnu.org Subject: [PATCH 02/18] hw/input/tsc210x: Extract common init code into new function Date: Mon, 25 Apr 2022 10:21:45 +0200 Message-Id: <1d75877cf4cc2a38f87633ff16f9fea3e1bb0c03.1650874791.git.mkletzan@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Stefan Hajnoczi , libvir-list@redhat.com, Christian Schoenebeck , Yanan Wang , Gerd Hoffmann , "Edgar E. Iglesias" , Qiuhao Li , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Marcel Apfelbaum , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Laurent Vivier , Thomas Huth , Alistair Francis , Alexander Bulekov , Bandan Das , qemu-arm@nongnu.org, Jan Kiszka , Pavel Dovgalyuk , Eduardo Habkost , Darren Kenny , Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1650874990541100013 Content-Type: text/plain; charset="utf-8"; x-default="true" This deduplicates several lines and will make future changes more concise. Signed-off-by: Martin Kletzander Reviewed-by: Daniel P. Berrang=C3=A9 --- 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" =20 #define TSC_DATA_REGISTERS_PAGE 0x0 #define TSC_CONTROL_REGISTERS_PAGE 0x1 @@ -1070,20 +1071,10 @@ static const VMStateDescription vmstate_tsc2301 =3D= { .fields =3D vmstatefields_tsc210x, }; =20 -uWireSlave *tsc2102_init(qemu_irq pint) +static void tsc210x_init(TSC210xState *s, + const char *name, + const VMStateDescription *vmsd) { - TSC210xState *s; - - s =3D g_new0(TSC210xState, 1); - s->x =3D 160; - s->y =3D 160; - s->pressure =3D 0; - s->precision =3D s->nextprecision =3D 0; - s->timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, tsc210x_timer_tick, s); - s->pint =3D pint; - s->model =3D 0x2102; - s->name =3D "tsc2102"; - s->tr[0] =3D 0; s->tr[1] =3D 1; s->tr[2] =3D 1; @@ -1105,13 +1096,29 @@ uWireSlave *tsc2102_init(qemu_irq pint) =20 tsc210x_reset(s); =20 - 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); =20 AUD_register_card(s->name, &s->card); =20 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 =3D g_new0(TSC210xState, 1); + s->x =3D 160; + s->y =3D 160; + s->pressure =3D 0; + s->precision =3D s->nextprecision =3D 0; + s->timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, tsc210x_timer_tick, s); + s->pint =3D pint; + s->model =3D 0x2102; + s->name =3D "tsc2102"; + + tsc210x_init(s, "QEMU TSC2102-driven Touchscreen", &vmstate_tsc2102); =20 return &s->chip; } @@ -1132,34 +1139,7 @@ uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq k= birq, qemu_irq dav) s->model =3D 0x2301; s->name =3D "tsc2301"; =20 - s->tr[0] =3D 0; - s->tr[1] =3D 1; - s->tr[2] =3D 1; - s->tr[3] =3D 0; - s->tr[4] =3D 1; - s->tr[5] =3D 0; - s->tr[6] =3D 1; - s->tr[7] =3D 0; - - s->chip.opaque =3D s; - s->chip.send =3D (void *) tsc210x_write; - s->chip.receive =3D (void *) tsc210x_read; - - s->codec.opaque =3D s; - s->codec.tx_swallow =3D (void *) tsc210x_i2s_swallow; - s->codec.set_rate =3D (void *) tsc210x_i2s_set_rate; - s->codec.in.fifo =3D s->in_fifo; - s->codec.out.fifo =3D 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); =20 return &s->chip; } --=20 2.35.1