From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33348) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YO52e-0002BM-Ir for qemu-devel@nongnu.org; Wed, 18 Feb 2015 08:51:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YO52Z-0002hh-GS for qemu-devel@nongnu.org; Wed, 18 Feb 2015 08:51:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35995) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YO52Z-0002hV-9H for qemu-devel@nongnu.org; Wed, 18 Feb 2015 08:51:47 -0500 Date: Wed, 18 Feb 2015 14:51:34 +0100 From: "Michael S. Tsirkin" Message-ID: <20150218135133.GA3083@redhat.com> References: <1423479254-15342-1-git-send-email-imammedo@redhat.com> <1423479254-15342-5-git-send-email-imammedo@redhat.com> <20150217195352.GA8388@redhat.com> <20150218104123.11f1c43b@nial.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150218104123.11f1c43b@nial.brq.redhat.com> Subject: Re: [Qemu-devel] [PATCH v3 04/52] acpi: factor out ACPI const int packing out of build_append_value() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: drjones@redhat.com, marcel.a@redhat.com, claudio.fontana@huawei.com, qemu-devel@nongnu.org, zhaoshenglong@huawei.com On Wed, Feb 18, 2015 at 10:41:23AM +0100, Igor Mammedov wrote: > On Tue, 17 Feb 2015 20:53:52 +0100 > "Michael S. Tsirkin" wrote: > > > On Mon, Feb 09, 2015 at 10:53:26AM +0000, Igor Mammedov wrote: > > > it will be reused for adding a plain integer value into AML. > > > > > > Signed-off-by: Igor Mammedov > > > --- > > > hw/acpi/aml-build.c | 19 +++---------------- > > > hw/i386/acpi-build.c | 6 +++--- > > > 2 files changed, 6 insertions(+), 19 deletions(-) > > > > > > diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c > > > index 096f347..67d1371 100644 > > > --- a/hw/acpi/aml-build.c > > > +++ b/hw/acpi/aml-build.c > > > @@ -221,24 +221,8 @@ void build_extop_package(GArray *package, uint8_t op) > > > > > > void build_append_value(GArray *table, uint32_t value, int size) > > > { > > > - uint8_t prefix; > > > int i; > > > > > > - switch (size) { > > > - case 1: > > > - prefix = 0x0A; /* BytePrefix */ > > > - break; > > > - case 2: > > > - prefix = 0x0B; /* WordPrefix */ > > > - break; > > > - case 4: > > > - prefix = 0x0C; /* DWordPrefix */ > > > - break; > > > - default: > > > - assert(0); > > > - return; > > > - } > > > - build_append_byte(table, prefix); > > > for (i = 0; i < size; ++i) { > > > build_append_byte(table, value & 0xFF); > > > value = value >> 8; > > > > This really makes this an awkward API, > > you must remember to add the prefix. > it's internal helper for adding plain values, > it's not intended for using outside aml-build.c > I should have marked it as static. > > [...] > > then call build_append_value_noprefix from build_append_value. > lets rename it to build_append_int_noprefix as int is less vague then value > and leave prefixed part as it's /i.e. build_append_int()/ > > > > > > But really, it's best to squash such changes with > > where they are used, it's just making review harder: > > as you add APIs with no documentation, I can't > > see what they do without reading follow up patch > > to see how they are used. > It's split out to make the rest of patches more review-able > if I drop aml_def_block() patch then this patch might be squashed with: > "acpi: extend build_append_{value|int}() to support 64-bit values" > "acpi: add aml_int() term" > and that might be squashed into already huge patch > "pc: acpi-build: drop template patching and create PCI bus tree dynamically" > > Squashing 3 different changes into a bigger patch doesn't make review any > easier and squashing that into 4th conversion patch makes it even worse. ok > > > > > > > @@ -252,10 +236,13 @@ void build_append_int(GArray *table, uint32_t value) > > > } else if (value == 0x01) { > > > build_append_byte(table, 0x01); /* OneOp */ > > > } else if (value <= 0xFF) { > > > + build_append_byte(table, 0x0A); /* BytePrefix */ > > > build_append_value(table, value, 1); > > > } else if (value <= 0xFFFF) { > > > + build_append_byte(table, 0x0B); /* WordPrefix */ > > > build_append_value(table, value, 2); > > > } else { > > > + build_append_byte(table, 0x0C); /* DWordPrefix */ > > > build_append_value(table, value, 4); > > > } > > > } > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c > > > index 788962e..a1bf450 100644 > > > --- a/hw/i386/acpi-build.c > > > +++ b/hw/i386/acpi-build.c > > > @@ -302,14 +302,14 @@ static void build_append_and_cleanup_method(GArray *device, GArray *method) > > > > > > static void build_append_notify_target_ifequal(GArray *method, > > > GArray *target_name, > > > - uint32_t value, int size) > > > + uint32_t value) > > > { > > > GArray *notify = build_alloc_array(); > > > uint8_t op = 0xA0; /* IfOp */ > > > > > > build_append_byte(notify, 0x93); /* LEqualOp */ > > > build_append_byte(notify, 0x68); /* Arg0Op */ > > > - build_append_value(notify, value, size); > > > + build_append_int(notify, value); > > > build_append_byte(notify, 0x86); /* NotifyOp */ > > > build_append_array(notify, target_name); > > > build_append_byte(notify, 0x69); /* Arg1Op */ > > > @@ -578,7 +578,7 @@ build_append_notify_method(GArray *device, const char *name, > > > GArray *target = build_alloc_array(); > > > build_append_namestring(target, format, i); > > > assert(i < 256); /* Fits in 1 byte */ > > > - build_append_notify_target_ifequal(method, target, i, 1); > > > + build_append_notify_target_ifequal(method, target, i); > > > build_free_array(target); > > > } > > > > > > -- > > > 1.8.3.1