From patchwork Fri Jun 23 10:39:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 9806233 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C382860349 for ; Fri, 23 Jun 2017 10:41:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A4C828682 for ; Fri, 23 Jun 2017 10:41:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4ED44286C4; Fri, 23 Jun 2017 10:41:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2367A2868F for ; Fri, 23 Jun 2017 10:41:02 +0000 (UTC) Received: from localhost ([::1]:34729 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dOM1O-0002od-0G for patchwork-qemu-devel@patchwork.kernel.org; Fri, 23 Jun 2017 06:41:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34421) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dOM0F-0002nk-Re for qemu-devel@nongnu.org; Fri, 23 Jun 2017 06:39:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dOM0D-00055r-86 for qemu-devel@nongnu.org; Fri, 23 Jun 2017 06:39:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50718) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dOM0D-00055Y-07 for qemu-devel@nongnu.org; Fri, 23 Jun 2017 06:39:49 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E98C0303154 for ; Fri, 23 Jun 2017 10:39:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E98C0303154 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E98C0303154 Received: from sirius.home.kraxel.org (ovpn-116-101.ams2.redhat.com [10.36.116.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F6EC6EC76; Fri, 23 Jun 2017 10:39:47 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id F112141CA2; Fri, 23 Jun 2017 12:39:45 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 23 Jun 2017 12:39:43 +0200 Message-Id: <20170623103945.7014-6-kraxel@redhat.com> In-Reply-To: <20170623103945.7014-1-kraxel@redhat.com> References: <20170623103945.7014-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 23 Jun 2017 10:39:48 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 5/7] ps2: add and use PS2State typedef X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Cleanup: Create and use a typedef for PS2State and stop passing void pointers. No functional change. Signed-off-by: Gerd Hoffmann Message-id: 20170606112105.13331-2-kraxel@redhat.com --- include/hw/input/ps2.h | 4 ++-- include/qemu/typedefs.h | 1 + hw/input/ps2.c | 12 +++++------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/include/hw/input/ps2.h b/include/hw/input/ps2.h index 7f0a80af9d..94709b8502 100644 --- a/include/hw/input/ps2.h +++ b/include/hw/input/ps2.h @@ -36,8 +36,8 @@ void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg); void *ps2_mouse_init(void (*update_irq)(void *, int), void *update_arg); void ps2_write_mouse(void *, int val); void ps2_write_keyboard(void *, int val); -uint32_t ps2_read_data(void *); -void ps2_queue(void *, int b); +uint32_t ps2_read_data(PS2State *s); +void ps2_queue(PS2State *s, int b); void ps2_keyboard_set_translation(void *opaque, int mode); void ps2_mouse_fake_event(void *opaque); diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index f745d5faf7..2706aabedf 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -76,6 +76,7 @@ typedef struct PixelFormat PixelFormat; typedef struct PostcopyDiscardState PostcopyDiscardState; typedef struct Property Property; typedef struct PropertyInfo PropertyInfo; +typedef struct PS2State PS2State; typedef struct QEMUBH QEMUBH; typedef struct QemuConsole QemuConsole; typedef struct QEMUFile QEMUFile; diff --git a/hw/input/ps2.c b/hw/input/ps2.c index 1d3a440bbd..37f8cb842e 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -85,12 +85,12 @@ typedef struct { int rptr, wptr, count; } PS2Queue; -typedef struct { +struct PS2State { PS2Queue queue; int32_t write_cmd; void (*update_irq)(void *, int); void *update_arg; -} PS2State; +}; typedef struct { PS2State common; @@ -551,9 +551,8 @@ static uint8_t translate_table[256] = { 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, }; -void ps2_queue(void *opaque, int b) +void ps2_queue(PS2State *s, int b) { - PS2State *s = (PS2State *)opaque; PS2Queue *q = &s->queue; if (q->count >= PS2_QUEUE_SIZE - 1) @@ -692,13 +691,12 @@ static void ps2_keyboard_event(DeviceState *dev, QemuConsole *src, } } -uint32_t ps2_read_data(void *opaque) +uint32_t ps2_read_data(PS2State *s) { - PS2State *s = (PS2State *)opaque; PS2Queue *q; int val, index; - trace_ps2_read_data(opaque); + trace_ps2_read_data(s); q = &s->queue; if (q->count == 0) { /* NOTE: if no data left, we return the last keyboard one