From nobody Thu Dec 18 22:15:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1740406274554607.9250047081023; Mon, 24 Feb 2025 06:11:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tmZAL-00067Y-AR; Mon, 24 Feb 2025 09:10:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tmZAI-00067D-R9; Mon, 24 Feb 2025 09:10:35 -0500 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tmZAG-0003D7-V8; Mon, 24 Feb 2025 09:10:34 -0500 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 2DE024E6039; Mon, 24 Feb 2025 15:10:28 +0100 (CET) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id TAViYdDBcBQT; Mon, 24 Feb 2025 15:10:26 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 3B36C4E6010; Mon, 24 Feb 2025 15:10:26 +0100 (CET) X-Virus-Scanned: amavisd-new at eik.bme.hu From: BALATON Zoltan Subject: [PATCH v2] hw/misc/macio/gpio.c: Add constants for register bits To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Mark Cave-Ayland , philmd@linaro.org Message-Id: <20250224141026.3B36C4E6010@zero.eik.bme.hu> Date: Mon, 24 Feb 2025 15:10:26 +0100 (CET) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, PP_MIME_FAKE_ASCII_TEXT=0.238, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1740406278649019100 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add named constants for register bit values that should make it easier to understand what these mean. Signed-off-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daud\ufffd\ufffd Reviewed-by: Mark Cave-Ayland --- hw/misc/macio/gpio.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/hw/misc/macio/gpio.c b/hw/misc/macio/gpio.c index 4364afc84a..e87bfca1f5 100644 --- a/hw/misc/macio/gpio.c +++ b/hw/misc/macio/gpio.c @@ -34,6 +34,11 @@ #include "qemu/module.h" #include "trace.h" =20 +enum MacioGPIORegisterBits { + OUT_DATA =3D 1, + IN_DATA =3D 2, + OUT_ENABLE =3D 4, +}; =20 void macio_set_gpio(MacIOGPIOState *s, uint32_t gpio, bool state) { @@ -41,14 +46,14 @@ void macio_set_gpio(MacIOGPIOState *s, uint32_t gpio, b= ool state) =20 trace_macio_set_gpio(gpio, state); =20 - if (s->gpio_regs[gpio] & 4) { + if (s->gpio_regs[gpio] & OUT_ENABLE) { qemu_log_mask(LOG_GUEST_ERROR, "GPIO: Setting GPIO %d while it's an output\n", gpio= ); } =20 - new_reg =3D s->gpio_regs[gpio] & ~2; + new_reg =3D s->gpio_regs[gpio] & ~IN_DATA; if (state) { - new_reg |=3D 2; + new_reg |=3D IN_DATA; } =20 if (new_reg =3D=3D s->gpio_regs[gpio]) { @@ -107,12 +112,12 @@ static void macio_gpio_write(void *opaque, hwaddr add= r, uint64_t value, =20 addr -=3D 8; if (addr < 36) { - value &=3D ~2; + value &=3D ~IN_DATA; =20 - if (value & 4) { - ibit =3D (value & 1) << 1; + if (value & OUT_ENABLE) { + ibit =3D (value & OUT_DATA) << 1; } else { - ibit =3D s->gpio_regs[addr] & 2; + ibit =3D s->gpio_regs[addr] & IN_DATA; } =20 s->gpio_regs[addr] =3D value | ibit; --=20 2.30.9