From nobody Wed Nov 5 13:59:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1498222242968319.3678409942962; Fri, 23 Jun 2017 05:50:42 -0700 (PDT) Received: from localhost ([::1]:35388 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dOO2p-0003HK-Ut for importer@patchew.org; Fri, 23 Jun 2017 08:50:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60094) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dOO0q-0001gG-O4 for qemu-devel@nongnu.org; Fri, 23 Jun 2017 08:48:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dOO0m-0004RP-DA for qemu-devel@nongnu.org; Fri, 23 Jun 2017 08:48:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39994) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dOO0m-0004P9-2H for qemu-devel@nongnu.org; Fri, 23 Jun 2017 08:48:32 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E4D94BC6A8; Fri, 23 Jun 2017 12:48:30 +0000 (UTC) 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 0708B6FB60; Fri, 23 Jun 2017 12:48:27 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 3B36F41ABE; Fri, 23 Jun 2017 14:48:29 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E4D94BC6A8 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E4D94BC6A8 From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 23 Jun 2017 14:48:27 +0200 Message-Id: <20170623124829.24260-2-kraxel@redhat.com> In-Reply-To: <20170623124829.24260-1-kraxel@redhat.com> References: <20170623124829.24260-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 23 Jun 2017 12:48:31 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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 1/3] applesmc: cosmetic whitespace and indentation cleanup 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: "Gabriel L. Somlo" , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: "Gabriel L. Somlo" Signed-off-by: Gabriel Somlo Reviewed-by: Alexander Graf Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Phil Dennis-Jordan Message-id: 1497639316-22202-2-git-send-email-gsomlo@gmail.com Signed-off-by: Gerd Hoffmann --- hw/misc/applesmc.c | 98 ++++++++++++++++++++++++++++----------------------= ---- 1 file changed, 50 insertions(+), 48 deletions(-) diff --git a/hw/misc/applesmc.c b/hw/misc/applesmc.c index 77fab5b9d2..6381197728 100644 --- a/hw/misc/applesmc.c +++ b/hw/misc/applesmc.c @@ -39,21 +39,24 @@ /* #define DEBUG_SMC */ =20 #define APPLESMC_DEFAULT_IOBASE 0x300 -/* data port used by Apple SMC */ -#define APPLESMC_DATA_PORT 0x0 -/* command/status port used by Apple SMC */ -#define APPLESMC_CMD_PORT 0x4 -#define APPLESMC_NR_PORTS 32 =20 -#define APPLESMC_READ_CMD 0x10 -#define APPLESMC_WRITE_CMD 0x11 -#define APPLESMC_GET_KEY_BY_INDEX_CMD 0x12 -#define APPLESMC_GET_KEY_TYPE_CMD 0x13 +enum { + APPLESMC_DATA_PORT =3D 0x00, + APPLESMC_CMD_PORT =3D 0x04, + APPLESMC_NUM_PORTS =3D 0x20, +}; + +enum { + APPLESMC_READ_CMD =3D 0x10, + APPLESMC_WRITE_CMD =3D 0x11, + APPLESMC_GET_KEY_BY_INDEX_CMD =3D 0x12, + APPLESMC_GET_KEY_TYPE_CMD =3D 0x13, +}; =20 #ifdef DEBUG_SMC #define smc_debug(...) fprintf(stderr, "AppleSMC: " __VA_ARGS__) #else -#define smc_debug(...) do { } while(0) +#define smc_debug(...) do { } while (0) #endif =20 static char default_osk[64] =3D "This is a dummy key. Enter the real key " @@ -77,12 +80,11 @@ struct AppleSMCState { uint32_t iobase; uint8_t cmd; uint8_t status; - uint8_t key[4]; + char key[4]; uint8_t read_pos; uint8_t data_len; uint8_t data_pos; uint8_t data[255]; - uint8_t charactic[4]; char *osk; QLIST_HEAD(, AppleSMCData) data_def; }; @@ -93,10 +95,10 @@ static void applesmc_io_cmd_write(void *opaque, hwaddr = addr, uint64_t val, AppleSMCState *s =3D opaque; =20 smc_debug("CMD Write B: %#x =3D %#x\n", addr, val); - switch(val) { - case APPLESMC_READ_CMD: - s->status =3D 0x0c; - break; + switch (val) { + case APPLESMC_READ_CMD: + s->status =3D 0x0c; + break; } s->cmd =3D val; s->read_pos =3D 0; @@ -123,54 +125,54 @@ static void applesmc_io_data_write(void *opaque, hwad= dr addr, uint64_t val, AppleSMCState *s =3D opaque; =20 smc_debug("DATA Write B: %#x =3D %#x\n", addr, val); - switch(s->cmd) { - case APPLESMC_READ_CMD: - if(s->read_pos < 4) { - s->key[s->read_pos] =3D val; - s->status =3D 0x04; - } else if(s->read_pos =3D=3D 4) { - s->data_len =3D val; - s->status =3D 0x05; - s->data_pos =3D 0; - smc_debug("Key =3D %c%c%c%c Len =3D %d\n", s->key[0], - s->key[1], s->key[2], s->key[3], val); - applesmc_fill_data(s); - } - s->read_pos++; - break; + switch (s->cmd) { + case APPLESMC_READ_CMD: + if (s->read_pos < 4) { + s->key[s->read_pos] =3D val; + s->status =3D 0x04; + } else if (s->read_pos =3D=3D 4) { + s->data_len =3D val; + s->status =3D 0x05; + s->data_pos =3D 0; + smc_debug("Key =3D %c%c%c%c Len =3D %d\n", s->key[0], + s->key[1], s->key[2], s->key[3], val); + applesmc_fill_data(s); + } + s->read_pos++; + break; } } =20 -static uint64_t applesmc_io_data_read(void *opaque, hwaddr addr1, - unsigned size) +static uint64_t applesmc_io_data_read(void *opaque, hwaddr addr, unsigned = size) { AppleSMCState *s =3D opaque; uint8_t retval =3D 0; =20 - switch(s->cmd) { - case APPLESMC_READ_CMD: - if(s->data_pos < s->data_len) { - retval =3D s->data[s->data_pos]; - smc_debug("READ_DATA[%d] =3D %#hhx\n", s->data_pos, - retval); - s->data_pos++; - if(s->data_pos =3D=3D s->data_len) { - s->status =3D 0x00; - smc_debug("EOF\n"); - } else - s->status =3D 0x05; + switch (s->cmd) { + case APPLESMC_READ_CMD: + if (s->data_pos < s->data_len) { + retval =3D s->data[s->data_pos]; + smc_debug("READ_DATA[%d] =3D %#hhx\n", s->data_pos, + retval); + s->data_pos++; + if (s->data_pos =3D=3D s->data_len) { + s->status =3D 0x00; + smc_debug("EOF\n"); + } else { + s->status =3D 0x05; } + } } - smc_debug("DATA Read b: %#x =3D %#x\n", addr1, retval); + smc_debug("DATA Read b: %#x =3D %#x\n", addr, retval); =20 return retval; } =20 -static uint64_t applesmc_io_cmd_read(void *opaque, hwaddr addr1, unsigned = size) +static uint64_t applesmc_io_cmd_read(void *opaque, hwaddr addr, unsigned s= ize) { AppleSMCState *s =3D opaque; =20 - smc_debug("CMD Read B: %#x\n", addr1); + smc_debug("CMD Read B: %#x\n", addr); return s->status; } =20 --=20 2.9.3