qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	qemu-devel@nongnu.org, Michael Tsirkin <mst@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 2/2] qbus: make bus reset overrideable by subclasses
Date: Fri, 11 Jan 2013 15:21:10 +0100	[thread overview]
Message-ID: <50F01FD6.6030408@redhat.com> (raw)
In-Reply-To: <1357913836-4560-3-git-send-email-aliguori@us.ibm.com>

Il 11/01/2013 15:17, Anthony Liguori ha scritto:
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
> ---
>  hw/qdev-core.h | 15 +++++++++++++++
>  hw/qdev.c      | 16 +++++++++++++++-
>  2 files changed, 30 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/qdev-core.h b/hw/qdev-core.h
> index f40fd15..453a061 100644
> --- a/hw/qdev-core.h
> +++ b/hw/qdev-core.h
> @@ -100,7 +100,22 @@ struct BusClass {
>       * bindings can be found at http://playground.sun.com/1275/bindings/.
>       */
>      char *(*get_fw_dev_path)(DeviceState *dev);
> +
> +    /**
> +     * reset:
> +     *
> +     * Cold reset of a bus. This only resets the controller state of the bus.
> +     */
>      int (*reset)(BusState *bus);
> +
> +    /**
> +     * reset_all:
> +     *
> +     * Cold reset of a bus with children.  The default implementation of this
> +     * method will invoke BusState::reset and then recursively call
> +     * qdev_reset_all() on each child in an arbitrary order.
> +     */
> +    void (*reset_all)(BusState *bus);
>  };
>  
>  typedef struct BusChild {
> diff --git a/hw/qdev.c b/hw/qdev.c
> index e02b5be..db19b14 100644
> --- a/hw/qdev.c
> +++ b/hw/qdev.c
> @@ -234,11 +234,17 @@ void qdev_reset_all(DeviceState *dev)
>      dc->reset_all(dev);
>  }
>  
> -void qbus_reset_all(BusState *bus)
> +static void qbus_reset_children(BusState *bus)
>  {
>      qbus_walk_children(bus, qdev_reset_one, qbus_reset_one, NULL);
>  }
>  
> +void qbus_reset_all(BusState *bus)
> +{
> +    BusClass *bc = BUS_GET_CLASS(bus);
> +    bc->reset_all(bus);
> +}
> +
>  void qbus_reset_all_fn(void *opaque)
>  {
>      BusState *bus = opaque;
> @@ -758,6 +764,13 @@ static const TypeInfo device_type_info = {
>      .class_size = sizeof(DeviceClass),
>  };
>  
> +static void qbus_class_initfn(ObjectClass *klass, void *data)
> +{
> +    BusClass *bc = BUS_CLASS(klass);
> +
> +    bc->reset_all = qbus_reset_children;
> +}
> +
>  static void qbus_initfn(Object *obj)
>  {
>      BusState *bus = BUS(obj);
> @@ -789,6 +802,7 @@ static const TypeInfo bus_info = {
>      .parent = TYPE_OBJECT,
>      .instance_size = sizeof(BusState),
>      .abstract = true,
> +    .class_init = qbus_class_initfn,
>      .class_size = sizeof(BusClass),
>      .instance_init = qbus_initfn,
>      .instance_finalize = qbus_finalize,
> 

Once you do this, the return value of bus->reset should become void, and
classes that used to return 1 should instead override reset_all.  Can
you do that too?

Paolo

  reply	other threads:[~2013-01-11 14:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-11 14:17 [Qemu-devel] [PATCH 0/2] qdev: make reset propagation overrideable by subclasses Anthony Liguori
2013-01-11 14:17 ` [Qemu-devel] [PATCH 1/2] " Anthony Liguori
2013-01-11 14:48   ` Andreas Färber
2013-01-11 14:17 ` [Qemu-devel] [PATCH 2/2] qbus: make bus reset " Anthony Liguori
2013-01-11 14:21   ` Paolo Bonzini [this message]
2013-01-11 14:48     ` Anthony Liguori

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=50F01FD6.6030408@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=mst@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).