From patchwork Thu Aug 21 09:47:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei (Arei)" X-Patchwork-Id: 381893 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 E6EEC140093 for ; Thu, 21 Aug 2014 19:48:52 +1000 (EST) Received: from localhost ([::1]:59787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKOzD-00053Q-57 for incoming@patchwork.ozlabs.org; Thu, 21 Aug 2014 05:48:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39863) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKOyh-0004Lu-Rr for qemu-devel@nongnu.org; Thu, 21 Aug 2014 05:48:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XKOyb-00016q-Ey for qemu-devel@nongnu.org; Thu, 21 Aug 2014 05:48:19 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:65047) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKOya-000162-Lr for qemu-devel@nongnu.org; Thu, 21 Aug 2014 05:48:13 -0400 Received: from 172.24.2.119 (EHLO szxeml404-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id BYL59777; Thu, 21 Aug 2014 17:47:59 +0800 (CST) Received: from localhost (10.177.19.102) by szxeml404-hub.china.huawei.com (10.82.67.59) with Microsoft SMTP Server id 14.3.158.1; Thu, 21 Aug 2014 17:47:50 +0800 From: To: Date: Thu, 21 Aug 2014 17:47:45 +0800 Message-ID: <1408614466-17596-2-git-send-email-arei.gonglei@huawei.com> X-Mailer: git-send-email 1.7.3.1.msysgit.0 In-Reply-To: <1408614466-17596-1-git-send-email-arei.gonglei@huawei.com> References: <1408614466-17596-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: peter.crosthwaite@xilinx.com, weidong.huang@huawei.com, mst@redhat.com, marcel.a@redhat.com, luonengjun@huawei.com, peter.huangpeng@huawei.com, armbru@redhat.com, Gonglei , imammedo@redhat.com, pbonzini@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH v2 1/2] qdev: Introduce a function to get qbus's parent 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 We need to use qbus's parent and get its name. Signed-off-by: Gonglei --- hw/core/qdev.c | 7 +++++++ include/hw/qdev-core.h | 1 + 2 files changed, 8 insertions(+) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index da1ba48..5c49e08 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -616,6 +616,13 @@ BusState *qbus_create(const char *typename, DeviceState *parent, const char *nam return bus; } +DeviceState *qbus_get_parent(BusState *bus) +{ + DeviceState *parent = bus->parent; + + return parent; +} + static char *bus_get_fw_dev_path(BusState *bus, DeviceState *dev) { BusClass *bc = BUS_GET_CLASS(bus); diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 0799ff2..760e726 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -301,6 +301,7 @@ typedef int (qdev_walkerfn)(DeviceState *dev, void *opaque); void qbus_create_inplace(void *bus, size_t size, const char *typename, DeviceState *parent, const char *name); BusState *qbus_create(const char *typename, DeviceState *parent, const char *name); +DeviceState *qbus_get_parent(BusState *bus); /* Returns > 0 if either devfn or busfn skip walk somewhere in cursion, * < 0 if either devfn or busfn terminate walk somewhere in cursion, * 0 otherwise. */