qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Artyom Tarasenko <atar4qemu@gmail.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Aleksandar Rikalo <arikalo@wavecomp.com>,
	Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
	qemu-devel <qemu-devel@nongnu.org>,
	Aleksandar Markovic <amarkovic@wavecomp.com>,
	Aurelien Jarno <aurelien@aurel32.net>
Subject: Re: [Qemu-devel] [PATCH 4/9] hw/misc/empty_slot: Add a qdev property 'size'
Date: Tue, 25 Jun 2019 09:09:11 +0200	[thread overview]
Message-ID: <CACXAS8BJBd0fJOhEo9pTfpnTB36+OPg-=Z0tCcxUYwPWho6Zqw@mail.gmail.com> (raw)
In-Reply-To: <20190624220056.25861-5-f4bug@amsat.org>

On Tue, Jun 25, 2019 at 12:01 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> Add a qdev 'size' property, check the size is not zero in the
> realize() function, simplify the empty_slot_init() logic.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Artyom Tarasenko <atar4qemu@gmail.com>

> ---
>  hw/misc/empty_slot.c | 43 ++++++++++++++++++++++++-------------------
>  1 file changed, 24 insertions(+), 19 deletions(-)
>
> diff --git a/hw/misc/empty_slot.c b/hw/misc/empty_slot.c
> index 53299cdbd1..ef0a7b99ba 100644
> --- a/hw/misc/empty_slot.c
> +++ b/hw/misc/empty_slot.c
> @@ -10,6 +10,7 @@
>   */
>
>  #include "qemu/osdep.h"
> +#include "qapi/error.h"
>  #include "hw/hw.h"
>  #include "hw/sysbus.h"
>  #include "qemu/module.h"
> @@ -55,41 +56,45 @@ static const MemoryRegionOps empty_slot_ops = {
>
>  void empty_slot_init(hwaddr addr, uint64_t slot_size)
>  {
> -    if (slot_size > 0) {
> -        /* Only empty slots larger than 0 byte need handling. */
> -        DeviceState *dev;
> -        SysBusDevice *s;
> -        EmptySlot *e;
> -
> -        dev = qdev_create(NULL, TYPE_EMPTY_SLOT);
> -        s = SYS_BUS_DEVICE(dev);
> -        e = EMPTY_SLOT(dev);
> -        e->size = slot_size;
> -
> -        qdev_init_nofail(dev);
> -
> -        /*
> -         * We use a priority lower than the default UNIMPLEMENTED_DEVICE
> -         * to be able to plug a UnimplementedDevice on an EmptySlot.
> -         */
> -        sysbus_mmio_map_overlap(s, 0, addr, -10000);
> -    }
> +    DeviceState *dev;
> +
> +    dev = qdev_create(NULL, TYPE_EMPTY_SLOT);
> +
> +    qdev_prop_set_uint64(dev, "size", slot_size);
> +    qdev_init_nofail(dev);
> +
> +    /*
> +     * We use a priority lower than the default UNIMPLEMENTED_DEVICE
> +     * to be able to plug a UnimplementedDevice on an EmptySlot.
> +     */
> +    sysbus_mmio_map_overlap(SYS_BUS_DEVICE(dev), 0, addr, -10000);
>  }
>
>  static void empty_slot_realize(DeviceState *dev, Error **errp)
>  {
>      EmptySlot *s = EMPTY_SLOT(dev);
>
> +    if (s->size == 0) {
> +        error_setg(errp, "property 'size' not specified or zero");
> +        return;
> +    }
> +
>      memory_region_init_io(&s->iomem, OBJECT(s), &empty_slot_ops, s,
>                            "empty-slot", s->size);
>      sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
>  }
>
> +static Property empty_slot_properties[] = {
> +    DEFINE_PROP_UINT64("size", EmptySlot, size, 0),
> +    DEFINE_PROP_END_OF_LIST(),
> +};
> +
>  static void empty_slot_class_init(ObjectClass *klass, void *data)
>  {
>      DeviceClass *dc = DEVICE_CLASS(klass);
>
>      dc->realize = empty_slot_realize;
> +    dc->props = empty_slot_properties;
>  }
>
>  static const TypeInfo empty_slot_info = {
> --
> 2.19.1
>


-- 
Regards,
Artyom Tarasenko

SPARC and PPC PReP under qemu blog: http://tyom.blogspot.com/search/label/qemu


  reply	other threads:[~2019-06-25  7:13 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-24 22:00 [Qemu-devel] [PATCH 0/9] hw/misc: Clean the empty_slot device Philippe Mathieu-Daudé
2019-06-24 22:00 ` [Qemu-devel] [PATCH 1/9] hw/misc: Move the 'empty_slot' device to hw/misc/ Philippe Mathieu-Daudé
2019-06-25  7:09   ` Artyom Tarasenko
2019-06-24 22:00 ` [Qemu-devel] [RFC PATCH 2/9] MAINTAINERS: Add the 'empty_slot' device with the 'unimp' one Philippe Mathieu-Daudé
2019-06-25  7:06   ` Artyom Tarasenko
2019-06-24 22:00 ` [Qemu-devel] [PATCH 3/9] hw/misc/empty_slot: Allow overide by device with higher priority Philippe Mathieu-Daudé
2019-06-25  7:08   ` Artyom Tarasenko
2019-06-24 22:00 ` [Qemu-devel] [PATCH 4/9] hw/misc/empty_slot: Add a qdev property 'size' Philippe Mathieu-Daudé
2019-06-25  7:09   ` Artyom Tarasenko [this message]
2019-06-24 22:00 ` [Qemu-devel] [PATCH 5/9] hw/misc/empty_slot: Add a qdev property 'name' Philippe Mathieu-Daudé
2019-06-25  7:05   ` Artyom Tarasenko
2019-06-24 22:00 ` [Qemu-devel] [PATCH 6/9] hw/misc/empty_slot: Convert debug printf()s to trace events Philippe Mathieu-Daudé
2019-06-25  7:04   ` Artyom Tarasenko
2019-06-24 22:00 ` [Qemu-devel] [PATCH 7/9] hw/sparc/sun4m: Mark some devices as 'unimplemented' Philippe Mathieu-Daudé
2019-06-25  7:16   ` Artyom Tarasenko
2019-06-24 22:00 ` [Qemu-devel] [PATCH 8/9] hw/sparc/sun4m: Simplify the RAM creation Philippe Mathieu-Daudé
2019-06-25  7:14   ` Artyom Tarasenko
2019-06-25  8:14     ` Philippe Mathieu-Daudé
2019-06-24 22:00 ` [Qemu-devel] [PATCH 9/9] hw/misc/empty_slot: Pass the slot name as argument Philippe Mathieu-Daudé
2019-06-25  7:03   ` Artyom Tarasenko

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='CACXAS8BJBd0fJOhEo9pTfpnTB36+OPg-=Z0tCcxUYwPWho6Zqw@mail.gmail.com' \
    --to=atar4qemu@gmail.com \
    --cc=amarkovic@wavecomp.com \
    --cc=arikalo@wavecomp.com \
    --cc=aurelien@aurel32.net \
    --cc=f4bug@amsat.org \
    --cc=mark.cave-ayland@ilande.co.uk \
    --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).