From patchwork Fri Jan 25 11:46:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 215637 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 84E1B2C008C for ; Fri, 25 Jan 2013 23:02:33 +1100 (EST) Received: from localhost ([::1]:41080 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyhzL-0005QW-Oc for incoming@patchwork.ozlabs.org; Fri, 25 Jan 2013 07:02:31 -0500 Received: from eggs.gnu.org ([208.118.235.92]:60842) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tyhz9-0005Nf-BH for qemu-devel@nongnu.org; Fri, 25 Jan 2013 07:02:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TyhkW-00058i-CQ for qemu-devel@nongnu.org; Fri, 25 Jan 2013 06:47:29 -0500 Received: from mail-qa0-f41.google.com ([209.85.216.41]:38359) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyhkW-00058N-3w for qemu-devel@nongnu.org; Fri, 25 Jan 2013 06:47:12 -0500 Received: by mail-qa0-f41.google.com with SMTP id hy16so149590qab.0 for ; Fri, 25 Jan 2013 03:47:11 -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; bh=JcrkF7Oau5JRzgTlTpCPb2c8nHahLCYBoj7I+vmGvL0=; b=G56VTYqAJSAhLj26sryhIFhqk3iB6QVEwHdZsvuo57SF+eTVl6Zh6wWA/wLkN6JqWH 5DO1vLbdHOysjYO9vuB0EL0tkVAh55Pxph/HtRBL2VNAFdSTuRLMMhiaDBG3hGY3IYRy TyVxRejiKldi9PiXFB/knMwRwBcDfN3dy6ytbTSGF1cmQcQx1QqUL7Yd25Ejkeqvb/b4 wBZsRt5NQbz1H6ApRUbNIOpxxRRilq52+o1Dh+Bx6yzBr3iql74HcgvO/KuGflXUdKrq pApWIOL8qKDwzkDzP2c1L5nZ6YBKjGHFYMgh23SiTwG9MihvU27M4DIBjU9hf4HEFyD4 fF+Q== X-Received: by 10.224.177.81 with SMTP id bh17mr5508656qab.26.1359114431154; Fri, 25 Jan 2013 03:47:11 -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 eg9sm419389qab.7.2013.01.25.03.47.09 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 25 Jan 2013 03:47:10 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 25 Jan 2013 12:46:49 +0100 Message-Id: <1359114420-16149-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1 In-Reply-To: <1359114420-16149-1-git-send-email-pbonzini@redhat.com> References: <1359114420-16149-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.216.41 Cc: afaerber@suse.de Subject: [Qemu-devel] [PATCH v3 01/12] 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. 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; }