From nobody Mon Feb 9 14:34:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150184260367460.18546263081703; Fri, 4 Aug 2017 03:30:03 -0700 (PDT) Received: from localhost ([::1]:55284 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddZrl-00072U-Nu for importer@patchew.org; Fri, 04 Aug 2017 06:30:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddZpy-0005Pn-64 for qemu-devel@nongnu.org; Fri, 04 Aug 2017 06:28:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddZpx-0002gE-4U for qemu-devel@nongnu.org; Fri, 04 Aug 2017 06:28:10 -0400 Received: from [183.91.158.132] (port=52073 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddZpr-0002S9-T8; Fri, 04 Aug 2017 06:28:04 -0400 Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 04 Aug 2017 18:27:53 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id 85A11472278E; Fri, 4 Aug 2017 18:27:53 +0800 (CST) Received: from maozy.g08.fujitsu.local (10.167.225.76) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 4 Aug 2017 18:27:52 +0800 X-IronPort-AV: E=Sophos;i="5.41,320,1498492800"; d="scan'208";a="22222196" From: Mao Zhongyi To: , Date: Fri, 4 Aug 2017 18:26:39 +0800 Message-ID: X-Mailer: git-send-email 2.9.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.167.225.76] X-yoursite-MailScanner-ID: 85A11472278E.AF49D X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: maozy.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 183.91.158.132 Subject: [Qemu-devel] [PATCH v2 2/6] hw/block/fdc: Convert to realize X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , John Snow , Markus Armbruster , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Convert floppy_drive_init() to realize and rename it to floppy_drive_realize(). Cc: John Snow Cc: Kevin Wolf Cc: Max Reitz Cc: Markus Armbruster Signed-off-by: Mao Zhongyi --- hw/block/fdc.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/hw/block/fdc.c b/hw/block/fdc.c index 4011290..02f4a46 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -517,7 +517,7 @@ static Property floppy_drive_properties[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 -static int floppy_drive_init(DeviceState *qdev) +static void floppy_drive_realize(DeviceState *qdev, Error **errp) { FloppyDrive *dev =3D FLOPPY_DRIVE(qdev); FloppyBus *bus =3D FLOPPY_BUS(qdev->parent_bus); @@ -535,15 +535,15 @@ static int floppy_drive_init(DeviceState *qdev) } =20 if (dev->unit >=3D MAX_FD) { - error_report("Can't create floppy unit %d, bus supports only %d un= its", - dev->unit, MAX_FD); - return -1; + error_setg(errp, "Can't create floppy unit %d, bus supports " + "only %d units", dev->unit, MAX_FD); + return; } =20 drive =3D get_drv(bus->fdc, dev->unit); if (drive->blk) { - error_report("Floppy unit %d is in use", dev->unit); - return -1; + error_setg(errp, "Floppy unit %d is in use", dev->unit); + return; } =20 if (!dev->conf.blk) { @@ -557,8 +557,9 @@ static int floppy_drive_init(DeviceState *qdev) if (dev->conf.logical_block_size !=3D 512 || dev->conf.physical_block_size !=3D 512) { - error_report("Physical and logical block size must be 512 for flop= py"); - return -1; + error_setg(errp, "Physical and logical block size must " + "be 512 for floppy"); + return; } =20 /* rerror/werror aren't supported by fdc and therefore not even regist= ered @@ -570,20 +571,20 @@ static int floppy_drive_init(DeviceState *qdev) blkconf_apply_backend_options(&dev->conf, blk_is_read_only(dev->conf.b= lk), false, &local_err); if (local_err) { - error_report_err(local_err); - return -1; + error_propagate(errp, local_err); + return; } =20 /* 'enospc' is the default for -drive, 'report' is what blk_new() give= s us * for empty drives. */ if (blk_get_on_error(dev->conf.blk, 0) !=3D BLOCKDEV_ON_ERROR_ENOSPC && blk_get_on_error(dev->conf.blk, 0) !=3D BLOCKDEV_ON_ERROR_REPORT) { - error_report("fdc doesn't support drive option werror"); - return -1; + error_setg(errp, "fdc doesn't support drive option werror"); + return; } if (blk_get_on_error(dev->conf.blk, 1) !=3D BLOCKDEV_ON_ERROR_REPORT) { - error_report("fdc doesn't support drive option rerror"); - return -1; + error_setg(errp, "fdc doesn't support drive option rerror"); + return; } =20 drive->conf =3D &dev->conf; @@ -599,14 +600,12 @@ static int floppy_drive_init(DeviceState *qdev) dev->type =3D drive->drive; =20 fd_revalidate(drive); - - return 0; } =20 static void floppy_drive_class_init(ObjectClass *klass, void *data) { DeviceClass *k =3D DEVICE_CLASS(klass); - k->init =3D floppy_drive_init; + k->realize =3D floppy_drive_realize; set_bit(DEVICE_CATEGORY_STORAGE, k->categories); k->bus_type =3D TYPE_FLOPPY_BUS; k->props =3D floppy_drive_properties; --=20 2.9.4