qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 1/2] qdev: Introduce a function to get qbus's


From: Gonglei (Arei)
Subject: Re: [Qemu-devel] [PATCH v2 1/2] qdev: Introduce a function to get qbus's parent
Date: Fri, 22 Aug 2014 02:01:17 +0000

> From: Hu Tao [mailto:address@hidden
> On Thu, Aug 21, 2014 at 05:47:45PM +0800, address@hidden wrote:
> > From: Gonglei <address@hidden>
> >
> > We need to use qbus's parent and get its name.
> >
> > Signed-off-by: Gonglei <address@hidden>
> > ---
> >  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;
> 

It should not happen, at the moment, but it is more safer, indeed.

Thanks.

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

Yes, it is simple. I just follow the realization of qdev_get_parent_bus()

Best regards,
-Gonglei

reply via email to

[Prev in Thread] Current Thread [Next in Thread]