From patchwork Fri Sep 19 06:48:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei (Arei)" X-Patchwork-Id: 391121 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8CCF6140187 for ; Fri, 19 Sep 2014 16:56:10 +1000 (EST) Received: from localhost ([::1]:56402 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUs6y-0006qx-Nc for incoming@patchwork.ozlabs.org; Fri, 19 Sep 2014 02:56:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40687) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUs0b-0003J3-KF for qemu-devel@nongnu.org; Fri, 19 Sep 2014 02:49:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XUs0V-0007XV-Au for qemu-devel@nongnu.org; Fri, 19 Sep 2014 02:49:33 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:43296) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUs0U-0007Ub-Dn for qemu-devel@nongnu.org; Fri, 19 Sep 2014 02:49:27 -0400 Received: from 172.24.2.119 (EHLO szxeml457-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id BZR13339; Fri, 19 Sep 2014 14:49:02 +0800 (CST) Received: from localhost (10.177.19.102) by szxeml457-hub.china.huawei.com (10.82.67.200) with Microsoft SMTP Server id 14.3.158.1; Fri, 19 Sep 2014 14:48:52 +0800 From: To: Date: Fri, 19 Sep 2014 14:48:26 +0800 Message-ID: <1411109321-15232-5-git-send-email-arei.gonglei@huawei.com> X-Mailer: git-send-email 1.7.3.1.msysgit.0 In-Reply-To: <1411109321-15232-1-git-send-email-arei.gonglei@huawei.com> References: <1411109321-15232-1-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.19.102] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.65 Cc: weidong.huang@huawei.com, luonengjun@huawei.com, peter.huangpeng@huawei.com, armbru@redhat.com, Gonglei , kraxel@redhat.com, pbonzini@redhat.com Subject: [Qemu-devel] [PATCH v3 04/19] libusb: convert init to 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: Gonglei In this way, all the implementations now use error_setg instead of error_report for reporting error. Signed-off-by: Gonglei Reviewed-by: Paolo Bonzini --- hw/usb/host-libusb.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c index 9f92705..dfb1750 100644 --- a/hw/usb/host-libusb.c +++ b/hw/usb/host-libusb.c @@ -951,21 +951,21 @@ static void usb_host_exit_notifier(struct Notifier *n, void *data) } } -static int usb_host_initfn(USBDevice *udev) +static void usb_host_realize(USBDevice *udev, Error **errp) { USBHostDevice *s = USB_HOST_DEVICE(udev); if (s->match.vendor_id > 0xffff) { - error_report("vendorid out of range"); - return -1; + error_setg(errp, "vendorid out of range"); + return; } if (s->match.product_id > 0xffff) { - error_report("productid out of range"); - return -1; + error_setg(errp, "productid out of range"); + return; } if (s->match.addr > 127) { - error_report("hostaddr out of range"); - return -1; + error_setg(errp, "hostaddr out of range"); + return; } loglevel = s->loglevel; @@ -980,7 +980,6 @@ static int usb_host_initfn(USBDevice *udev) QTAILQ_INSERT_TAIL(&hostdevs, s, next); add_boot_device_path(s->bootindex, &udev->qdev, NULL); usb_host_auto_check(NULL); - return 0; } static void usb_host_handle_destroy(USBDevice *udev) @@ -1480,7 +1479,7 @@ static void usb_host_class_initfn(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); USBDeviceClass *uc = USB_DEVICE_CLASS(klass); - uc->init = usb_host_initfn; + uc->realize = usb_host_realize; uc->product_desc = "USB Host Device"; uc->cancel_packet = usb_host_cancel_packet; uc->handle_data = usb_host_handle_data;