All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hu Tao <hutao@cn.fujitsu.com>
To: arei.gonglei@huawei.com
Cc: peter.crosthwaite@xilinx.com, weidong.huang@huawei.com,
	marcel.a@redhat.com, armbru@redhat.com, mst@redhat.com,
	luonengjun@huawei.com, qemu-devel@nongnu.org,
	peter.huangpeng@huawei.com, pbonzini@redhat.com,
	imammedo@redhat.com, afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH v2 1/2] qdev: Introduce a function to get qbus's parent
Date: Fri, 22 Aug 2014 09:17:41 +0800	[thread overview]
Message-ID: <20140822011741.GA10441@G08FNSTD100614.fnst.cn.fujitsu.com> (raw)
In-Reply-To: <1408614466-17596-2-git-send-email-arei.gonglei@huawei.com>

On Thu, Aug 21, 2014 at 05:47:45PM +0800, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
> 
> We need to use qbus's parent and get its name.
> 
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
>  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;
> +}

You can return bus->parent directly, or safer:

if (bus) {
    return bus->parent;
}

return NULL;

And, the function is simple enough to make it inline.

> +
>  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
> 
> 

  reply	other threads:[~2014-08-22  1:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-21  9:47 [Qemu-devel] [PATCH v2 0/2] add check for PCIe root ports and downstream ports arei.gonglei
2014-08-21  9:47 ` [Qemu-devel] [PATCH v2 1/2] qdev: Introduce a function to get qbus's parent arei.gonglei
2014-08-22  1:17   ` Hu Tao [this message]
2014-08-22  2:01     ` Gonglei (Arei)
2014-08-21  9:47 ` [Qemu-devel] [PATCH v2 2/2] pci: add check for pcie root ports and downstream ports arei.gonglei
2014-08-22  6:33   ` Marcel Apfelbaum
2014-08-22  6:40     ` Gonglei (Arei)
2014-08-25  8:59   ` Knut Omang
2014-08-25  9:23     ` Gonglei (Arei)
2014-08-25  9:51       ` Knut Omang
2014-08-25 10:51         ` Gonglei (Arei)
2014-08-25 11:01           ` Knut Omang
2014-08-25 11:23             ` Gonglei (Arei)
2014-08-26 14:34               ` Knut Omang
2014-08-25 20:02   ` Michael S. Tsirkin
2014-08-26 10:07     ` Gonglei (Arei)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140822011741.GA10441@G08FNSTD100614.fnst.cn.fujitsu.com \
    --to=hutao@cn.fujitsu.com \
    --cc=afaerber@suse.de \
    --cc=arei.gonglei@huawei.com \
    --cc=armbru@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=luonengjun@huawei.com \
    --cc=marcel.a@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=weidong.huang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.