From: Fabien Chouteau <chouteau@adacore.com>
To: "Andreas Färber" <afaerber@suse.de>, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, mark.cave-ayland@ilande.co.uk,
Jiri Gaisler <jiri@gaisler.se>
Subject: Re: [Qemu-devel] [PATCH][SPARC] LEON3: Add emulation of AMBA plug&play
Date: Thu, 09 Oct 2014 10:43:37 +0200 [thread overview]
Message-ID: <54364AB9.1090500@adacore.com> (raw)
In-Reply-To: <54355A7C.8060007@suse.de>
On 10/08/2014 05:38 PM, Andreas Färber wrote:
> Hi,
>
Hi Andreas,
> Am 08.10.2014 um 16:19 schrieb Fabien Chouteau:
>> From: Jiri Gaisler <jiri@gaisler.se>
>>
>> +
>> +#define TYPE_GRLIB_APB_PNP "grlib,apbpnp"
>
> If you move the two TYPE_* constants to grlib.h, you can reuse them.
>
Will do.
>> +#define GRLIB_APB_PNP(obj) \
>> + OBJECT_CHECK(APBPNP, (obj), TYPE_GRLIB_APB_PNP)
>> +
>> +typedef struct APBPNP {
>> + SysBusDevice parent_obj;
>> + MemoryRegion iomem;
>> +} APBPNP;
>> +
>> +static uint64_t grlib_apbpnp_read(void *opaque, hwaddr addr,
>> + unsigned size)
>
> Indentation is off by one for all read/write functions.
>
Are you sure? The indentation is 4 spaces right? (checkpatch.pl didn't
raise any error).
>> +static int grlib_apbpnp_init(SysBusDevice *dev)
>> +{
>> + APBPNP *pnp = GRLIB_APB_PNP(dev);
>> +
>> + memory_region_init_io(&pnp->iomem, OBJECT(pnp), &grlib_apbpnp_ops, pnp,
>> + "apbpnp", APBPNP_REG_SIZE);
>> +
>> + sysbus_init_mmio(dev, &pnp->iomem);
>
> APBPNP_REG_SIZE seems constant, so you could move both lines into an
> instance_init function.
>
Will do. I don't need a .class_init then.
>> +
>> + k->init = grlib_apbpnp_init;
>> +}
>> +
>> +static const TypeInfo grlib_apbpnp_info = {
>> + .name = TYPE_GRLIB_APB_PNP,
>> + .parent = TYPE_SYS_BUS_DEVICE,
>> + .instance_size = sizeof(APBPNP),
>> + .class_init = grlib_apbpnp_class_init,
>> +};
>> +
>> +static void grlib_apbpnp_register_types(void)
>> +{
>> + type_register_static(&grlib_apbpnp_info);
>> +}
>> +
>> +type_init(grlib_apbpnp_register_types)
>
> Please either split into two .c files here, ...
>
>>
> ... or if unavoidable use just one type_init and registration function.
> +
I will create one type init for both memory regions.
>> +static inline
>> +DeviceState *grlib_ahbpnp_create(hwaddr base)
>> +{
>> + DeviceState *dev;
>> +
>> + dev = qdev_create(NULL, "grlib,ahbpnp");
>> +
>> + if (qdev_init(dev)) {
>> + return NULL;
>> + }
>> +
>> + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
>> +
>> + return dev;
>> +}
>> +
>> #endif /* ! _GRLIB_H_ */
>
> Are these functions really needed? Can't you just inline them?
> Also note that the return value is never actually checked.
>
This is what we do for all GRLIB devices, I think it makes a cleaner
machine init.
Thanks for the review.
prev parent reply other threads:[~2014-10-09 8:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-08 14:19 [Qemu-devel] [PATCH][SPARC] LEON3: Add emulation of AMBA plug&play Fabien Chouteau
2014-10-08 15:38 ` Andreas Färber
2014-10-08 19:43 ` Jiri Gaisler
2014-10-09 9:21 ` Fabien Chouteau
2014-10-09 8:43 ` Fabien Chouteau [this message]
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=54364AB9.1090500@adacore.com \
--to=chouteau@adacore.com \
--cc=afaerber@suse.de \
--cc=jiri@gaisler.se \
--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).