All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: BALATON Zoltan <balaton@eik.bme.hu>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	qemu-trivial@nongnu.org, qemu-devel@nongnu.org,
	Beniamino Galvani <b.galvani@gmail.com>,
	Niek Linnenbank <nieklinnenbank@gmail.com>,
	qemu-arm@nongnu.org, qemu-ppc@nongnu.org,
	David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [PATCH 2/2] hw/ppc: Use TYPE_SYSBUS_OHCI instead of hardcoded string
Date: Fri, 3 Jul 2020 23:57:00 +0200	[thread overview]
Message-ID: <fabe84fc-af53-a945-8b43-e2893853da6c@amsat.org> (raw)
In-Reply-To: <alpine.BSF.2.22.395.2007032149250.12670@zero.eik.bme.hu>

On 7/3/20 9:58 PM, BALATON Zoltan wrote:
> On Fri, 3 Jul 2020, Philippe Mathieu-Daudé wrote:
>> By using the TYPE_* definitions for devices, we can:
>> - quickly find where devices are used with 'git-grep'
> 
> You could just as well grep for the type name but it's true if some
> files use name and others the constant then you need to grep for both.
> 
>> - easily rename a non-user-creatable device (one-line change).
> 
> But most devices are user creatable and thus their name is part of the
> CLI so inlikely to change due to preserving backward compatibility of
> command lines. So usefulness of this change seems limited to me.
> 
> But my problem with it is not the above. It's that hcd-ohci.h is not in
> include but in hw/usb so it's internal to the implementation of the
> device model and defines things that users of the device should not
> need, therefore they should not include this header. So if you want to
> use the defined constant then that should be split off to some public
> header instead of including hw/usb/hcd-ohci.h. Maybe we need a new
> header for these TYPE_* constants similar to qemu/typedefs.h?

Indeed you are right. Thanks for noticing the bad effect of my patch.

> 
> Regards,
> BALATON Zoltan
> 
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>> hw/display/sm501.c | 3 ++-
>> hw/ppc/sam460ex.c  | 3 ++-
>> 2 files changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/display/sm501.c b/hw/display/sm501.c
>> index 9cccc68c35..c122a4eca5 100644
>> --- a/hw/display/sm501.c
>> +++ b/hw/display/sm501.c
>> @@ -36,6 +36,7 @@
>> #include "hw/qdev-properties.h"
>> #include "hw/i2c/i2c.h"
>> #include "hw/display/i2c-ddc.h"
>> +#include "hw/usb/hcd-ohci.h"
>> #include "qemu/range.h"
>> #include "ui/pixel_ops.h"
>> #include "qemu/bswap.h"
>> @@ -1961,7 +1962,7 @@ static void sm501_realize_sysbus(DeviceState
>> *dev, Error **errp)
>>     sysbus_init_mmio(sbd, &s->state.mmio_region);
>>
>>     /* bridge to usb host emulation module */
>> -    usb_dev = qdev_new("sysbus-ohci");
>> +    usb_dev = qdev_new(TYPE_SYSBUS_OHCI);
>>     qdev_prop_set_uint32(usb_dev, "num-ports", 2);
>>     qdev_prop_set_uint64(usb_dev, "dma-offset", s->base);
>>     sysbus_realize_and_unref(SYS_BUS_DEVICE(usb_dev), &error_fatal);
>> diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
>> index 1a106a68de..593436937a 100644
>> --- a/hw/ppc/sam460ex.c
>> +++ b/hw/ppc/sam460ex.c
>> @@ -35,6 +35,7 @@
>> #include "hw/char/serial.h"
>> #include "hw/i2c/ppc4xx_i2c.h"
>> #include "hw/i2c/smbus_eeprom.h"
>> +#include "hw/usb/hcd-ohci.h"
>> #include "hw/usb/hcd-ehci.h"
>> #include "hw/ppc/fdt.h"
>> #include "hw/qdev-properties.h"
>> @@ -370,7 +371,7 @@ static void sam460ex_init(MachineState *machine)
>>
>>     /* USB */
>>     sysbus_create_simple(TYPE_PPC4xx_EHCI, 0x4bffd0400, uic[2][29]);
>> -    dev = qdev_new("sysbus-ohci");
>> +    dev = qdev_new(TYPE_SYSBUS_OHCI);
>>     qdev_prop_set_string(dev, "masterbus", "usb-bus.0");
>>     qdev_prop_set_uint32(dev, "num-ports", 6);
>>     sbdev = SYS_BUS_DEVICE(dev);
>>


  reply	other threads:[~2020-07-03 21:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-03 18:49 [PATCH 0/2] hw: Use TYPE_SYSBUS_OHCI instead of hardcoded string Philippe Mathieu-Daudé
2020-07-03 18:49 ` [PATCH 1/2] hw/arm: " Philippe Mathieu-Daudé
2020-07-03 21:29   ` Niek Linnenbank
2020-07-03 18:49 ` [PATCH 2/2] hw/ppc: " Philippe Mathieu-Daudé
2020-07-03 19:58   ` BALATON Zoltan
2020-07-03 21:57     ` Philippe Mathieu-Daudé [this message]
2020-07-05  5:34   ` 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=fabe84fc-af53-a945-8b43-e2893853da6c@amsat.org \
    --to=f4bug@amsat.org \
    --cc=b.galvani@gmail.com \
    --cc=balaton@eik.bme.hu \
    --cc=david@gibson.dropbear.id.au \
    --cc=nieklinnenbank@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=qemu-trivial@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.