From: David Gibson <david@gibson.dropbear.id.au>
To: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 6/7] mac_dbdma: change DBDMA_register_channel to a MAC_DBDMA type method
Date: Tue, 26 Sep 2017 13:47:06 +1000 [thread overview]
Message-ID: <20170926034706.GG12504@umbus> (raw)
In-Reply-To: <1506264466-28252-7-git-send-email-mark.cave-ayland@ilande.co.uk>
[-- Attachment #1: Type: text/plain, Size: 5042 bytes --]
On Sun, Sep 24, 2017 at 03:47:45PM +0100, Mark Cave-Ayland wrote:
> Using this we can change the MACIO_IDE instance to register the channel
> itself via a type method instead of requiring a separate
> DBDMA_register_channel() function.
>
> As a consequence of this it is now possible to remove the old external
> macio_ide_register_dma() function.
>
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Ok, two concerns about this.
First, you've added the function pointer to the instance, not to the
class, which is not how a QOM method would normally be done.
More generally, though, why is a method preferable to a plain
function? AFAICT it's not plausible that there will ever be more than
one implementation of the method.
Same comments apply to patch 7/7.
> ---
> hw/ide/macio.c | 12 ++++++------
> hw/misc/macio/mac_dbdma.c | 9 +++++----
> hw/misc/macio/macio.c | 1 -
> include/hw/ppc/mac_dbdma.h | 9 ++++-----
> 4 files changed, 15 insertions(+), 16 deletions(-)
>
> diff --git a/hw/ide/macio.c b/hw/ide/macio.c
> index ce194c6..b296017 100644
> --- a/hw/ide/macio.c
> +++ b/hw/ide/macio.c
> @@ -411,12 +411,18 @@ static const IDEDMAOps dbdma_ops = {
> static void macio_ide_realizefn(DeviceState *dev, Error **errp)
> {
> MACIOIDEState *s = MACIO_IDE(dev);
> + DBDMAState *dbdma;
>
> ide_init2(&s->bus, s->ide_irq);
>
> /* Register DMA callbacks */
> s->dma.ops = &dbdma_ops;
> s->bus.dma = &s->dma;
> +
> + /* Register DBDMA channel */
> + dbdma = MAC_DBDMA(object_property_get_link(OBJECT(dev), "dbdma", errp));
> + dbdma->register_channel(dbdma, s->channel, s->dma_irq,
> + pmac_ide_transfer, pmac_ide_flush, s);
> }
>
> static void pmac_ide_irq(void *opaque, int n, int level)
> @@ -497,10 +503,4 @@ void macio_ide_init_drives(MACIOIDEState *s, DriveInfo **hd_table)
> }
> }
>
> -void macio_ide_register_dma(MACIOIDEState *s)
> -{
> - DBDMA_register_channel(s->dbdma, s->channel, s->dma_irq,
> - pmac_ide_transfer, pmac_ide_flush, s);
> -}
> -
> type_init(macio_ide_register_types)
> diff --git a/hw/misc/macio/mac_dbdma.c b/hw/misc/macio/mac_dbdma.c
> index 0eddf2e..addb97d 100644
> --- a/hw/misc/macio/mac_dbdma.c
> +++ b/hw/misc/macio/mac_dbdma.c
> @@ -557,11 +557,10 @@ void DBDMA_kick(DBDMAState *dbdma)
> qemu_bh_schedule(dbdma->bh);
> }
>
> -void DBDMA_register_channel(void *dbdma, int nchan, qemu_irq irq,
> - DBDMA_rw rw, DBDMA_flush flush,
> - void *opaque)
> +static void
> +dbdma_register_channel(DBDMAState *s, int nchan, qemu_irq irq,
> + DBDMA_rw rw, DBDMA_flush flush, void *opaque)
> {
> - DBDMAState *s = dbdma;
> DBDMA_channel *ch = &s->channels[nchan];
>
> DBDMA_DPRINTFCH(ch, "DBDMA_register_channel 0x%x\n", nchan);
> @@ -903,6 +902,8 @@ static void mac_dbdma_init(Object *obj)
>
> memory_region_init_io(&s->mem, obj, &dbdma_ops, s, "dbdma", 0x1000);
> sysbus_init_mmio(sbd, &s->mem);
> +
> + s->register_channel = dbdma_register_channel;
> }
>
> static void mac_dbdma_realize(DeviceState *dev, Error **errp)
> diff --git a/hw/misc/macio/macio.c b/hw/misc/macio/macio.c
> index 9aa7e75..533331a 100644
> --- a/hw/misc/macio/macio.c
> +++ b/hw/misc/macio/macio.c
> @@ -161,7 +161,6 @@ static void macio_realize_ide(MacIOState *s, MACIOIDEState *ide,
> sysbus_connect_irq(sysbus_dev, 1, irq1);
> qdev_prop_set_uint32(DEVICE(ide), "channel", dmaid);
> object_property_set_link(OBJECT(ide), OBJECT(s->dbdma), "dbdma", errp);
> - macio_ide_register_dma(ide);
>
> object_property_set_bool(OBJECT(ide), true, "realized", errp);
> }
> diff --git a/include/hw/ppc/mac_dbdma.h b/include/hw/ppc/mac_dbdma.h
> index 26cc469..d6a38c5 100644
> --- a/include/hw/ppc/mac_dbdma.h
> +++ b/include/hw/ppc/mac_dbdma.h
> @@ -160,19 +160,18 @@ typedef struct DBDMA_channel {
> dbdma_cmd current;
> } DBDMA_channel;
>
> -typedef struct {
> +typedef struct DBDMAState {
> SysBusDevice parent_obj;
>
> MemoryRegion mem;
> DBDMA_channel channels[DBDMA_CHANNELS];
> QEMUBH *bh;
> +
> + void (*register_channel)(struct DBDMAState *s, int nchan, qemu_irq irq,
> + DBDMA_rw rw, DBDMA_flush flush, void *opaque);
> } DBDMAState;
>
> /* Externally callable functions */
> -
> -void DBDMA_register_channel(void *dbdma, int nchan, qemu_irq irq,
> - DBDMA_rw rw, DBDMA_flush flush,
> - void *opaque);
> void DBDMA_kick(DBDMAState *dbdma);
>
> #define TYPE_MAC_DBDMA "mac-dbdma"
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2017-09-26 3:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-24 14:47 [Qemu-devel] [PATCH 0/7] mac_dbdma: tidy-up and QOMify Mark Cave-Ayland
2017-09-24 14:47 ` [Qemu-devel] [PATCH 1/7] mac_dbdma: remove unused IO fields from DBDMAState Mark Cave-Ayland
2017-09-24 14:47 ` [Qemu-devel] [PATCH 2/7] mac_dbdma: QOMify Mark Cave-Ayland
2017-09-24 14:47 ` [Qemu-devel] [PATCH 3/7] mac_dbdma: remove DBDMA_init() function Mark Cave-Ayland
2017-09-24 14:47 ` [Qemu-devel] [PATCH 4/7] macio: pass channel into MACIOIDEState via qdev property Mark Cave-Ayland
2017-09-24 14:47 ` [Qemu-devel] [PATCH 5/7] macio: use object link between MACIO_IDE and MAC_DBDMA object Mark Cave-Ayland
2017-09-24 14:47 ` [Qemu-devel] [PATCH 6/7] mac_dbdma: change DBDMA_register_channel to a MAC_DBDMA type method Mark Cave-Ayland
2017-09-26 3:47 ` David Gibson [this message]
2017-09-28 6:40 ` Mark Cave-Ayland
2017-09-30 3:23 ` David Gibson
2017-09-24 14:47 ` [Qemu-devel] [PATCH 7/7] mac_dbdma: change DBDMA_kick " Mark Cave-Ayland
2017-09-25 23:49 ` [Qemu-devel] [PATCH 0/7] mac_dbdma: tidy-up and QOMify David Gibson
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=20170926034706.GG12504@umbus \
--to=david@gibson.dropbear.id.au \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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).