Received: from eggs.gnu.org ([2001:4830:134:3::10]:42531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VYewJ-0005z5-OZ for qemu-devel@nongnu.org; Tue, 22 Oct 2013 12:36:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VYewB-0001yn-DW for qemu-devel@nongnu.org; Tue, 22 Oct 2013 12:36:15 -0400 Received: from mail-pb0-f48.google.com ([209.85.160.48]:53268) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VYewB-0001yc-7X for qemu-devel@nongnu.org; Tue, 22 Oct 2013 12:36:07 -0400 Received: by mail-pb0-f48.google.com with SMTP id ma3so8857188pbc.35 for ; Tue, 22 Oct 2013 09:36:06 -0700 (PDT) From: Roy Franz Date: Tue, 22 Oct 2013 09:35:55 -0700 Message-Id: <1382459756-6853-4-git-send-email-roy.franz@linaro.org> In-Reply-To: <1382459756-6853-1-git-send-email-roy.franz@linaro.org> References: <1382459756-6853-1-git-send-email-roy.franz@linaro.org> Subject: [Qemu-devel] [PATCH 3/4 v4] block: return status for each device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, kwolf@redhat.com, stefanha@redhat.com Cc: Roy Franz , peter.maydell@linaro.org, patches@linaro.org Now that we know how wide each flash device that makes up the bank is, return status for each device in the bank. Leave existing code that treats 32 bit wide banks as composed of two 16 bit devices as otherwise we may break configurations that do not set the device_width propery. Signed-off-by: Roy Franz --- hw/block/pflash_cfi01.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index cda8289..aa2cbbc 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -191,9 +191,21 @@ static uint32_t pflash_read (pflash_t *pfl, hwaddr offset, case 0x60: /* Block /un)lock */ case 0x70: /* Status Register */ case 0xe8: /* Write block */ - /* Status register read */ + /* Status register read. Return status from each device in + * bank. + */ ret = pfl->status; - if (width > 2) { + if (width > pfl->device_width) { + int shift = pfl->device_width * 8; + while (shift + pfl->device_width * 8 <= width * 8) { + ret |= pfl->status << (shift); + shift += pfl->device_width * 8; + } + } else if (width > 2) { + /* Handle 32 bit flash cases where device width may be + * improperly set. (Existing behavior before device width + * added.) + */ ret |= pfl->status << 16; } DPRINTF("%s: status %x\n", __func__, ret); -- 1.7.10.4