qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>,
	Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org,
	Kevin Wolf <kwolf@redhat.com>
Subject: Re: [PATCH v2 5/6] hw/input/stellaris_input: Convert to qdev
Date: Tue, 31 Oct 2023 15:55:14 +0100	[thread overview]
Message-ID: <59d6df3c-95ee-4ac4-9ac4-3f4ed49708fa@linaro.org> (raw)
In-Reply-To: <CAFEAcA_4wqP7G+gXnunJx85OTvUr-3kx6HGABGb6Kt3y=b_Nvw@mail.gmail.com>

On 31/10/23 15:05, Peter Maydell wrote:
> On Tue, 31 Oct 2023 at 13:55, Peter Maydell <peter.maydell@linaro.org> wrote:
>>
>> On Mon, 30 Oct 2023 at 20:38, Mark Cave-Ayland
>> <mark.cave-ayland@ilande.co.uk> wrote:
>>>
>>> On 30/10/2023 11:48, Peter Maydell wrote:
>>> Is it worth converting this to use DEFINE_TYPES() during the conversion? I know Phil
>>> has considered some automation to remove the type_init() boilerplate for the majority
>>> of cases.
>>
>> I could, I guess. It seems a bit awkward that DEFINE_TYPES()
>> wants you to pass it an array even when you only have one type,
>> though, which is going to be a very common use case.

For single type, there is no point beside enforcing a QOM style.

I'll update docs/devel/qom.rst...

> I'm going to squash this into this patch:
> diff --git a/hw/input/stellaris_gamepad.c b/hw/input/stellaris_gamepad.c
> index 6ccf0e80adc..d42ba4f0582 100644
> --- a/hw/input/stellaris_gamepad.c
> +++ b/hw/input/stellaris_gamepad.c
> @@ -90,16 +90,13 @@ static void
> stellaris_gamepad_class_init(ObjectClass *klass, void *data)
>       device_class_set_props(dc, stellaris_gamepad_properties);
>   }
> 
> -static const TypeInfo stellaris_gamepad_info = {
> -    .name = TYPE_STELLARIS_GAMEPAD,
> -    .parent = TYPE_SYS_BUS_DEVICE,
> -    .instance_size = sizeof(StellarisGamepad),
> -    .class_init = stellaris_gamepad_class_init,
> +static const TypeInfo stellaris_gamepad_info[] = {
> +    {
> +        .name = TYPE_STELLARIS_GAMEPAD,
> +        .parent = TYPE_SYS_BUS_DEVICE,
> +        .instance_size = sizeof(StellarisGamepad),
> +        .class_init = stellaris_gamepad_class_init,
> +    },
>   };
> 
> -static void stellaris_gamepad_register_types(void)
> -{
> -    type_register_static(&stellaris_gamepad_info);
> -}
> -
> -type_init(stellaris_gamepad_register_types);
> +DEFINE_TYPES(stellaris_gamepad_info);
> 
> 
> The array is a bit awkward, but it's overall better than having
> to define the register-types function.

Thank you!


  reply	other threads:[~2023-10-31 14:56 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-30 11:47 [PATCH v2 0/6] arm/stellaris: convert gamepad input device to qdev Peter Maydell
2023-10-30 11:47 ` [PATCH v2 1/6] hw/input/stellaris_input: Rename to stellaris_gamepad Peter Maydell
2023-10-30 11:47 ` [PATCH v2 2/6] hw/input/stellaris_gamepad: Rename structs to our usual convention Peter Maydell
2023-10-30 11:47 ` [PATCH v2 3/6] qdev: Add qdev_prop_set_array() Peter Maydell
2023-10-30 11:48 ` [PATCH v2 4/6] hw/input/stellaris_gamepad: Remove StellarisGamepadButton struct Peter Maydell
2023-10-30 11:48 ` [PATCH v2 5/6] hw/input/stellaris_input: Convert to qdev Peter Maydell
2023-10-30 13:52   ` Philippe Mathieu-Daudé
2023-10-30 14:25     ` Markus Armbruster
2023-10-31  8:16       ` Philippe Mathieu-Daudé
2023-10-30 14:41     ` Peter Maydell
2023-10-30 18:28       ` Philippe Mathieu-Daudé
2023-10-30 20:37   ` Mark Cave-Ayland
2023-10-31 13:55     ` Peter Maydell
2023-10-31 14:05       ` Peter Maydell
2023-10-31 14:55         ` Philippe Mathieu-Daudé [this message]
2023-10-31 15:36           ` Peter Maydell
2023-10-30 11:48 ` [PATCH v2 6/6] hw/input/stellaris_gamepad: Convert to qemu_input_handler_register() Peter Maydell

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=59d6df3c-95ee-4ac4-9ac4-3f4ed49708fa@linaro.org \
    --to=philmd@linaro.org \
    --cc=kwolf@redhat.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.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).