From patchwork Tue Jun 18 11:11:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Crosthwaite X-Patchwork-Id: 252234 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3CD812C009D for ; Tue, 18 Jun 2013 21:18:47 +1000 (EST) Received: from localhost ([::1]:43471 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uotvx-0006Ey-9R for incoming@patchwork.ozlabs.org; Tue, 18 Jun 2013 07:18:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47615) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UotvM-0005d0-EU for qemu-devel@nongnu.org; Tue, 18 Jun 2013 07:18:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UotvL-0001wb-7G for qemu-devel@nongnu.org; Tue, 18 Jun 2013 07:18:08 -0400 Received: from mail-pb0-x22e.google.com ([2607:f8b0:400e:c01::22e]:46923) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UotvL-0001wW-0p for qemu-devel@nongnu.org; Tue, 18 Jun 2013 07:18:07 -0400 Received: by mail-pb0-f46.google.com with SMTP id rq2so3809221pbb.19 for ; Tue, 18 Jun 2013 04:18:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=3cHAp3VfBhzu0xeS0tuZ3+hUwKb28e1h7AVoRBFhIjc=; b=SVox/7gk/PHUKxqPq2Rq+VPExafJmHZY49thwhHiJDJ/jQpfsFWbEc9FjftAA0zVY3 anoA0gnPIt8KyKPhPMKix+ISLfbq55Aqq+fky1UISjtJhskj1GOenaTQ1fvECxoWGS/8 ++wFXAU8dw5+a2z795NVO3W9PPhM4ywTeOaIQm7uHP7eo6ZSEIFh3XPi08VjGQEaQFh5 K7vcCatAoBov/qbplgmpRmZg3BJLAekKU7J0vNGdAeVYjWmAjFR8yIWCOK/EPxQhHTzv C49vCKS3fjgaM7pa3DYfnZJHukBjeH9iIymWNhdirNPzYSNARIdTx8bX+5S0w5Fl44AT 6GzQ== X-Received: by 10.68.252.36 with SMTP id zp4mr16966599pbc.51.1371554286281; Tue, 18 Jun 2013 04:18:06 -0700 (PDT) Received: from localhost ([203.126.243.116]) by mx.google.com with ESMTPSA id re16sm19181607pac.16.2013.06.18.04.18.02 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Tue, 18 Jun 2013 04:18:05 -0700 (PDT) From: peter.crosthwaite@xilinx.com To: qemu-devel@nongnu.org Date: Tue, 18 Jun 2013 21:11:52 +1000 Message-Id: X-Mailer: git-send-email 1.8.3.rc1.44.gb387c77.dirty In-Reply-To: References: X-Gm-Message-State: ALoCoQlsWFAkVdjV39wgwr2ufDQ3x/Fc7l05P81deeD4WiL2gxVw595CGbLi4j30WlpDjoLykgSx X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c01::22e Cc: peter.maydell@linaro.org, Peter Crosthwaite , afaerber@suse.de, edgar.iglesias@gmail.com Subject: [Qemu-devel] [PATCH v1 4/5] block/nand: Convert Sysbus::init to Device::realize X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Peter Crosthwaite The prescribed transition from Sysbus::init function to a Device::realize. Cc: afaerber@suse.de Signed-off-by: Peter Crosthwaite Reviewed-by: Andreas Färber --- hw/block/nand.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/hw/block/nand.c b/hw/block/nand.c index d2469f5..8dca3bc 100644 --- a/hw/block/nand.c +++ b/hw/block/nand.c @@ -367,7 +367,7 @@ static const VMStateDescription vmstate_nand = { } }; -static int nand_device_init(SysBusDevice *dev) +static void nand_realize(DeviceState *dev, Error **errp) { int pagesize; NANDFlashState *s = NAND(dev); @@ -393,16 +393,17 @@ static int nand_device_init(SysBusDevice *dev) nand_init_2048(s); break; default: - error_report("Unsupported NAND block size"); - return -1; + error_setg(errp, "Unsupported NAND block size %#x\n", + 1 << s->page_shift); + return; } pagesize = 1 << s->oob_shift; s->mem_oob = 1; if (s->bdrv) { if (bdrv_is_read_only(s->bdrv)) { - error_report("Can't use a read-only drive"); - return -1; + error_setg(errp, "Can't use a read-only drive"); + return; } if (bdrv_getlength(s->bdrv) >= (s->pages << s->page_shift) + (s->pages << s->oob_shift)) { @@ -418,8 +419,6 @@ static int nand_device_init(SysBusDevice *dev) } /* Give s->ioaddr a sane value in case we save state before it is used. */ s->ioaddr = s->io; - - return 0; } static Property nand_properties[] = { @@ -432,9 +431,8 @@ static Property nand_properties[] = { static void nand_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); - k->init = nand_device_init; + dc->realize = nand_realize; dc->reset = nand_reset; dc->vmsd = &vmstate_nand; dc->props = nand_properties;