From patchwork Fri Jan 25 13:12:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 215785 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A83E92C007C for ; Sat, 26 Jan 2013 02:53:19 +1100 (EST) Received: from localhost ([::1]:40007 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tyj64-0007Of-Nd for incoming@patchwork.ozlabs.org; Fri, 25 Jan 2013 08:13:32 -0500 Received: from eggs.gnu.org ([208.118.235.92]:49055) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tyj5X-0007C0-KS for qemu-devel@nongnu.org; Fri, 25 Jan 2013 08:13:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tyj5O-00026V-Ku for qemu-devel@nongnu.org; Fri, 25 Jan 2013 08:12:59 -0500 Received: from mail-qa0-f48.google.com ([209.85.216.48]:62766) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tyj5O-00026N-Dy for qemu-devel@nongnu.org; Fri, 25 Jan 2013 08:12:50 -0500 Received: by mail-qa0-f48.google.com with SMTP id j8so215000qah.0 for ; Fri, 25 Jan 2013 05:12:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:mime-version:content-type :content-transfer-encoding; bh=ipo571ZRsK0NCiCNzhKsXCDOetm3EWGNxAskRMcMsCo=; b=cYs0RsJWmHuSI7lMxFVfZ79ha2MxQKG3UoEmI2Xwwrhw5L5wS+NDipPOyaBDGZ2XHG MuGi+Xsa3/kkvKsxRVy58NApDOcKOBTCNwn5UzZ4A1cffq8NPgP5XpDuqttO3pyIcwDW uN1PERfl0yJZDViIWZzAm3lNDs5/UV0CgcZ6frcvN1lcSOXvLgxGPgAsG+ZcquY0CfVL Ol68ObO/rlcuw+fy7yndF5635dWIg/Ds9y55K81mRjw4HQWYiLe3XMNUCX11SzOn0sLm 6V4Nc2+JOIf928tjBol2HIF+faeF9PjjeiCUxdYGnxLA0YejzBJ24NRHW85E68/yqLTh MD4w== X-Received: by 10.224.59.135 with SMTP id l7mr5662141qah.25.1359119570044; Fri, 25 Jan 2013 05:12:50 -0800 (PST) Received: from yakj.usersys.redhat.com (93-34-179-137.ip50.fastwebnet.it. [93.34.179.137]) by mx.google.com with ESMTPS id u8sm416277qeu.2.2013.01.25.05.12.47 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 25 Jan 2013 05:12:49 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 25 Jan 2013 14:12:27 +0100 Message-Id: <1359119559-19075-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1 In-Reply-To: <1359119559-19075-1-git-send-email-pbonzini@redhat.com> References: <1359119559-19075-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.216.48 Cc: afaerber@suse.de Subject: [Qemu-devel] [PATCH v4 01/13] qdev: remove duplication between qbus_create and qbus_create_inplace 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 Move the common part to qbus_realize. Acked-by: Andreas Färber Signed-off-by: Paolo Bonzini --- hw/qdev.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index 9761016..59dce62 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -390,14 +390,16 @@ DeviceState *qdev_find_recursive(BusState *bus, const char *id) return NULL; } -static void qbus_realize(BusState *bus) +static void qbus_realize(BusState *bus, DeviceState *parent, const char *name) { const char *typename = object_get_typename(OBJECT(bus)); char *buf; int i,len; - if (bus->name) { - /* use supplied name */ + bus->parent = parent; + + if (name) { + bus->name = g_strdup(name); } else if (bus->parent && bus->parent->id) { /* parent device has id -> use it for bus name */ len = strlen(bus->parent->id) + 16; @@ -430,10 +432,7 @@ void qbus_create_inplace(BusState *bus, const char *typename, DeviceState *parent, const char *name) { object_initialize(bus, typename); - - bus->parent = parent; - bus->name = name ? g_strdup(name) : NULL; - qbus_realize(bus); + qbus_realize(bus, parent, name); } BusState *qbus_create(const char *typename, DeviceState *parent, const char *name) @@ -441,10 +440,7 @@ BusState *qbus_create(const char *typename, DeviceState *parent, const char *nam BusState *bus; bus = BUS(object_new(typename)); - - bus->parent = parent; - bus->name = name ? g_strdup(name) : NULL; - qbus_realize(bus); + qbus_realize(bus, parent, name); return bus; }