qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH arm-devs v4 4/4] cpu/a9mpcore: Add Global Timer


From: Andreas Färber
Subject: Re: [Qemu-devel] [PATCH arm-devs v4 4/4] cpu/a9mpcore: Add Global Timer
Date: Mon, 02 Dec 2013 14:56:15 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0

Am 02.12.2013 14:21, schrieb Paolo Bonzini:
> Il 02/12/2013 14:08, Andreas Färber ha scritto:
>>>> +    object_initialize(&s->gtimer, sizeof(s->gtimer), TYPE_A9_GTIMER);
>>>> +    qdev_set_parent_bus(DEVICE(&s->gtimer), sysbus_get_default());
>>>> +
>>>>      object_initialize(&s->mptimer, sizeof(s->mptimer), TYPE_ARM_MPTIMER);
>>>>      qdev_set_parent_bus(DEVICE(&s->mptimer), sysbus_get_default());
>>>>  
>> This code resulted from inlining qdev_create() and switching to in-place
>> instantiation.
>>
>> Seeing this repetitive code again and again makes me wonder whether we
>> can just set a SysBusDevice's parent_bus in its instance_init function
>> to simplify it?
> 
> Could we do it instead in the init function, only if parent_bus is still
> NULL?

I'll interpret that as realize function. ;)

Apart from assuming that no sysbus_*() or qdev_*() API depends on the
bus being non-NULL, converted SysBusDevices have started to assume that
SysBusDevice itself has no realize implementation. (At the time, we'd
have needed to know what it does to determine when to call parent_*.)
It would also make SysBusDevices differ from all others, which I find
not so nice.

Most devices will be instantiated with qdev_create(NULL, ...), so it may
be feasible to just drop the NULL -> sysbus_get_default() conversion
there and for device_add(), leaving only 14 occurrences to convert in
qemu.git. :)

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



reply via email to

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