Received: from eggs.gnu.org ([2001:4830:134:3::10]:37591) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XORi6-0003wx-QU for qemu-devel@nongnu.org; Mon, 01 Sep 2014 09:32:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XORi1-00006B-79 for qemu-devel@nongnu.org; Mon, 01 Sep 2014 09:31:54 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:39858) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XORhz-0007f8-Cz for qemu-devel@nongnu.org; Mon, 01 Sep 2014 09:31:49 -0400 From: Date: Mon, 1 Sep 2014 21:29:17 +0800 Message-ID: <1409578159-9576-2-git-send-email-arei.gonglei@huawei.com> In-Reply-To: <1409578159-9576-1-git-send-email-arei.gonglei@huawei.com> References: <1409578159-9576-1-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH v3 1/3] qdev: Introduce a function to get qbus's parent List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 From: Gonglei We may use it check type of qbus's parent. Signed-off-by: Gonglei --- hw/core/qdev.c | 9 +++++++++ include/hw/qdev-core.h | 1 + 2 files changed, 10 insertions(+) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index da1ba48..e42d313 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -616,6 +616,15 @@ BusState *qbus_create(const char *typename, DeviceState *parent, const char *nam return bus; } +DeviceState *qbus_get_parent(BusState *bus) +{ + if (bus) { + return bus->parent; + } + + return NULL; +} + 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. */ -- 1.7.12.4