From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59704) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xy6xF-0000Aw-JH for qemu-devel@nongnu.org; Mon, 08 Dec 2014 17:39:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xy6x9-0004NK-D3 for qemu-devel@nongnu.org; Mon, 08 Dec 2014 17:38:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58736) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xy6x9-0004N7-3j for qemu-devel@nongnu.org; Mon, 08 Dec 2014 17:38:51 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sB8Mca4Q024383 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 8 Dec 2014 17:38:50 -0500 Date: Mon, 8 Dec 2014 22:54:03 +0200 From: "Michael S. Tsirkin" Message-ID: <20141208205403.GF29909@redhat.com> References: <1418054888-11310-1-git-send-email-imammedo@redhat.com> <1418054888-11310-8-git-send-email-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1418054888-11310-8-git-send-email-imammedo@redhat.com> Subject: Re: [Qemu-devel] [PATCH 7/9] acpi: replace opencoded notify codes with named values List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: qemu-devel@nongnu.org, marcel.a@redhat.com On Mon, Dec 08, 2014 at 04:08:06PM +0000, Igor Mammedov wrote: > Signed-off-by: Igor Mammedov I'm not sure this makes sense for these constants. Device Check seems more readable than ACPI_DEV_CHK. If your object here is readability, please do not abbreviate. Generally ability to match spec names exactly is what made me prefer code comments to enums for one-off constants. Looking up "Device Check" works in any spec version, I don't have to dig up the exact one, find table by name, break my eyes trying to locate the correct line in a huge table. Just text search, and the correct line is highlighted. Why look in another spec version you might ask? Well it's definitely helpful to understand legacy guest quirks. > --- > hw/i386/acpi-build.c | 4 ++-- > include/hw/acpi/acpi_gen_utils.h | 6 ++++++ > 2 files changed, 8 insertions(+), 2 deletions(-) > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c > index 0f6202d..a33d130 100644 > --- a/hw/i386/acpi-build.c > +++ b/hw/i386/acpi-build.c > @@ -840,10 +840,10 @@ static void build_pci_bus_end(PCIBus *bus, void *bus_state) > build_append_namestring(method, "BNUM"); > build_append_namestring(method, "DVNT"); > build_append_namestring(method, "PCIU"); > - build_append_int(method, 1); /* Device Check */ > + build_append_int(method, ACPI_DEV_CHK); > build_append_namestring(method, "DVNT"); > build_append_namestring(method, "PCID"); > - build_append_int(method, 3); /* Eject Request */ > + build_append_int(method, ACPI_DEV_EJ); > } > > /* Notify about child bus events in any case */ > diff --git a/include/hw/acpi/acpi_gen_utils.h b/include/hw/acpi/acpi_gen_utils.h > index fd50625..ce76dc1 100644 > --- a/include/hw/acpi/acpi_gen_utils.h > +++ b/include/hw/acpi/acpi_gen_utils.h > @@ -5,6 +5,12 @@ > #include > #include "qemu/compiler.h" > > +/* ACPI 5.0: table "Device Object Notification Values" */ > +enum { > + ACPI_DEV_CHK = 1, > + ACPI_DEV_EJ = 3, > +}; > + > GArray *build_alloc_array(void); > void build_free_array(GArray *array); > void build_prepend_byte(GArray *array, uint8_t val); > -- > 1.8.3.1