* [PATCH 1/3] hw/usb: Style cleanup
2024-02-13 4:38 [PATCH 0/3] hw/usb: Rename NB_PORTS -> UHCI_PORTS / EHCI_PORTS Philippe Mathieu-Daudé
@ 2024-02-13 4:38 ` Philippe Mathieu-Daudé
2024-02-13 4:38 ` [PATCH 2/3] hw/usb/uhci: Rename NB_PORTS -> UHCI_PORTS Philippe Mathieu-Daudé
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-02-13 4:38 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Gerd Hoffmann, Philippe Mathieu-Daudé
We are going to modify these lines, fix their style
in order to avoid checkpatch.pl warning.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/usb/hcd-ehci.c | 3 ++-
hw/usb/hcd-uhci.c | 6 ++++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index 870c72cb59..98a2860069 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -1086,8 +1086,9 @@ static void ehci_opreg_write(void *ptr, hwaddr addr,
case CONFIGFLAG:
val &= 0x1;
if (val) {
- for(i = 0; i < NB_PORTS; i++)
+ for (i = 0; i < NB_PORTS; i++) {
handle_port_owner_write(s, i, 0);
+ }
}
break;
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index 7d3c026dae..b95b47f6a4 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -457,8 +457,9 @@ static void uhci_port_write(void *opaque, hwaddr addr,
int n;
n = (addr >> 1) & 7;
- if (n >= NB_PORTS)
+ if (n >= NB_PORTS) {
return;
+ }
port = &s->ports[n];
dev = port->port.dev;
if (dev && dev->attached) {
@@ -513,8 +514,9 @@ static uint64_t uhci_port_read(void *opaque, hwaddr addr, unsigned size)
UHCIPort *port;
int n;
n = (addr >> 1) & 7;
- if (n >= NB_PORTS)
+ if (n >= NB_PORTS) {
goto read_default;
+ }
port = &s->ports[n];
val = port->ctrl;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] hw/usb/uhci: Rename NB_PORTS -> UHCI_PORTS
2024-02-13 4:38 [PATCH 0/3] hw/usb: Rename NB_PORTS -> UHCI_PORTS / EHCI_PORTS Philippe Mathieu-Daudé
2024-02-13 4:38 ` [PATCH 1/3] hw/usb: Style cleanup Philippe Mathieu-Daudé
@ 2024-02-13 4:38 ` Philippe Mathieu-Daudé
2024-02-13 4:38 ` [PATCH 3/3] hw/usb/ehci: Rename NB_PORTS -> EHCI_PORTS Philippe Mathieu-Daudé
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-02-13 4:38 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Gerd Hoffmann, Philippe Mathieu-Daudé
Rename NB_PORTS as UHCI_PORTS to avoid definition clash
with EHCI equivalent:
hw/usb/hcd-uhci.h:38:9: error: 'NB_PORTS' macro redefined [-Werror,-Wmacro-redefined]
#define NB_PORTS 2
^
hw/usb/hcd-ehci.h:40:9: note: previous definition is here
#define NB_PORTS 6 /* Max. Number of downstream ports */
^
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/usb/hcd-uhci.h | 4 ++--
hw/usb/hcd-uhci.c | 22 +++++++++++-----------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/hw/usb/hcd-uhci.h b/hw/usb/hcd-uhci.h
index 69f8b40c49..6d26b94e92 100644
--- a/hw/usb/hcd-uhci.h
+++ b/hw/usb/hcd-uhci.h
@@ -35,7 +35,7 @@
typedef struct UHCIQueue UHCIQueue;
-#define NB_PORTS 2
+#define UHCI_PORTS 2
typedef struct UHCIPort {
USBPort port;
@@ -59,7 +59,7 @@ typedef struct UHCIState {
uint32_t frame_bytes;
uint32_t frame_bandwidth;
bool completions_only;
- UHCIPort ports[NB_PORTS];
+ UHCIPort ports[UHCI_PORTS];
qemu_irq irq;
/* Interrupts that should be raised at the end of the current frame. */
uint32_t pending_int_mask;
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index b95b47f6a4..a03cf22e69 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -322,7 +322,7 @@ static void uhci_reset(DeviceState *dev)
s->fl_base_addr = 0;
s->sof_timing = 64;
- for(i = 0; i < NB_PORTS; i++) {
+ for(i = 0; i < UHCI_PORTS; i++) {
port = &s->ports[i];
port->ctrl = 0x0080;
if (port->port.dev && port->port.dev->attached) {
@@ -364,7 +364,7 @@ static const VMStateDescription vmstate_uhci = {
.fields = (const VMStateField[]) {
VMSTATE_PCI_DEVICE(dev, UHCIState),
VMSTATE_UINT8_EQUAL(num_ports_vmstate, UHCIState, NULL),
- VMSTATE_STRUCT_ARRAY(ports, UHCIState, NB_PORTS, 1,
+ VMSTATE_STRUCT_ARRAY(ports, UHCIState, UHCI_PORTS, 1,
vmstate_uhci_port, UHCIPort),
VMSTATE_UINT16(cmd, UHCIState),
VMSTATE_UINT16(status, UHCIState),
@@ -404,7 +404,7 @@ static void uhci_port_write(void *opaque, hwaddr addr,
int i;
/* send reset on the USB bus */
- for(i = 0; i < NB_PORTS; i++) {
+ for(i = 0; i < UHCI_PORTS; i++) {
port = &s->ports[i];
usb_device_reset(port->port.dev);
}
@@ -457,7 +457,7 @@ static void uhci_port_write(void *opaque, hwaddr addr,
int n;
n = (addr >> 1) & 7;
- if (n >= NB_PORTS) {
+ if (n >= UHCI_PORTS) {
return;
}
port = &s->ports[n];
@@ -514,7 +514,7 @@ static uint64_t uhci_port_read(void *opaque, hwaddr addr, unsigned size)
UHCIPort *port;
int n;
n = (addr >> 1) & 7;
- if (n >= NB_PORTS) {
+ if (n >= UHCI_PORTS) {
goto read_default;
}
port = &s->ports[n];
@@ -609,7 +609,7 @@ static USBDevice *uhci_find_device(UHCIState *s, uint8_t addr)
USBDevice *dev;
int i;
- for (i = 0; i < NB_PORTS; i++) {
+ for (i = 0; i < UHCI_PORTS; i++) {
UHCIPort *port = &s->ports[i];
if (!(port->ctrl & UHCI_PORT_EN)) {
continue;
@@ -1173,11 +1173,11 @@ void usb_uhci_common_realize(PCIDevice *dev, Error **errp)
s->irq = pci_allocate_irq(dev);
if (s->masterbus) {
- USBPort *ports[NB_PORTS];
- for(i = 0; i < NB_PORTS; i++) {
+ USBPort *ports[UHCI_PORTS];
+ for(i = 0; i < UHCI_PORTS; i++) {
ports[i] = &s->ports[i].port;
}
- usb_register_companion(s->masterbus, ports, NB_PORTS,
+ usb_register_companion(s->masterbus, ports, UHCI_PORTS,
s->firstport, s, &uhci_port_ops,
USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL,
&err);
@@ -1187,14 +1187,14 @@ void usb_uhci_common_realize(PCIDevice *dev, Error **errp)
}
} else {
usb_bus_new(&s->bus, sizeof(s->bus), &uhci_bus_ops, DEVICE(dev));
- for (i = 0; i < NB_PORTS; i++) {
+ for (i = 0; i < UHCI_PORTS; i++) {
usb_register_port(&s->bus, &s->ports[i].port, s, i, &uhci_port_ops,
USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL);
}
}
s->bh = qemu_bh_new_guarded(uhci_bh, s, &DEVICE(dev)->mem_reentrancy_guard);
s->frame_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, uhci_frame_timer, s);
- s->num_ports_vmstate = NB_PORTS;
+ s->num_ports_vmstate = UHCI_PORTS;
QTAILQ_INIT(&s->queues);
memory_region_init_io(&s->io_bar, OBJECT(s), &uhci_ioport_ops, s,
--
2.41.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] hw/usb/ehci: Rename NB_PORTS -> EHCI_PORTS
2024-02-13 4:38 [PATCH 0/3] hw/usb: Rename NB_PORTS -> UHCI_PORTS / EHCI_PORTS Philippe Mathieu-Daudé
2024-02-13 4:38 ` [PATCH 1/3] hw/usb: Style cleanup Philippe Mathieu-Daudé
2024-02-13 4:38 ` [PATCH 2/3] hw/usb/uhci: Rename NB_PORTS -> UHCI_PORTS Philippe Mathieu-Daudé
@ 2024-02-13 4:38 ` Philippe Mathieu-Daudé
2024-02-13 6:35 ` [PATCH 0/3] hw/usb: Rename NB_PORTS -> UHCI_PORTS / EHCI_PORTS Richard Henderson
2024-02-13 18:12 ` Michael Tokarev
4 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-02-13 4:38 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Gerd Hoffmann, Philippe Mathieu-Daudé
Rename NB_PORTS as EHCI_PORTS to avoid definition clash
with UHCI equivalent:
hw/usb/hcd-ehci.h:40:9: error: 'NB_PORTS' macro redefined [-Werror,-Wmacro-redefined]
#define NB_PORTS 6 /* Max. Number of downstream ports */
^
hw/usb/hcd-uhci.h:38:9: note: previous definition is here
#define NB_PORTS 2
^
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/usb/hcd-ehci.h | 8 ++++----
hw/usb/hcd-ehci-pci.c | 2 +-
hw/usb/hcd-ehci-sysbus.c | 2 +-
hw/usb/hcd-ehci.c | 20 ++++++++++----------
4 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h
index 2cd821f49e..56a1c09d1f 100644
--- a/hw/usb/hcd-ehci.h
+++ b/hw/usb/hcd-ehci.h
@@ -37,7 +37,7 @@
#define MMIO_SIZE 0x1000
#define CAPA_SIZE 0x10
-#define NB_PORTS 6 /* Max. Number of downstream ports */
+#define EHCI_PORTS 6 /* Max. Number of downstream ports */
typedef struct EHCIPacket EHCIPacket;
typedef struct EHCIQueue EHCIQueue;
@@ -288,7 +288,7 @@ struct EHCIState {
uint32_t configflag;
};
};
- uint32_t portsc[NB_PORTS];
+ uint32_t portsc[EHCI_PORTS];
/*
* Internal states, shadow registers, etc
@@ -298,8 +298,8 @@ struct EHCIState {
bool working;
uint32_t astate; /* Current state in asynchronous schedule */
uint32_t pstate; /* Current state in periodic schedule */
- USBPort ports[NB_PORTS];
- USBPort *companion_ports[NB_PORTS];
+ USBPort ports[EHCI_PORTS];
+ USBPort *companion_ports[EHCI_PORTS];
uint32_t usbsts_pending;
uint32_t usbsts_frindex;
EHCIQueueHead aqueues;
diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c
index 0b26db74d8..3ff54edf62 100644
--- a/hw/usb/hcd-ehci-pci.c
+++ b/hw/usb/hcd-ehci-pci.c
@@ -83,7 +83,7 @@ static void usb_ehci_pci_init(Object *obj)
s->capsbase = 0x00;
s->opregbase = 0x20;
s->portscbase = 0x44;
- s->portnr = NB_PORTS;
+ s->portnr = EHCI_PORTS;
if (!dc->hotpluggable) {
s->companion_enable = true;
diff --git a/hw/usb/hcd-ehci-sysbus.c b/hw/usb/hcd-ehci-sysbus.c
index bfb774504c..fe1dabd0bb 100644
--- a/hw/usb/hcd-ehci-sysbus.c
+++ b/hw/usb/hcd-ehci-sysbus.c
@@ -88,7 +88,7 @@ static void ehci_sysbus_class_init(ObjectClass *klass, void *data)
SysBusEHCIClass *sec = SYS_BUS_EHCI_CLASS(klass);
sec->portscbase = 0x44;
- sec->portnr = NB_PORTS;
+ sec->portnr = EHCI_PORTS;
dc->realize = usb_ehci_sysbus_realize;
dc->vmsd = &vmstate_ehci_sysbus;
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index 98a2860069..01864d4649 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -783,9 +783,9 @@ static void ehci_register_companion(USBBus *bus, USBPort *ports[],
EHCIState *s = container_of(bus, EHCIState, bus);
uint32_t i;
- if (firstport + portcount > NB_PORTS) {
+ if (firstport + portcount > EHCI_PORTS) {
error_setg(errp, "firstport must be between 0 and %u",
- NB_PORTS - portcount);
+ EHCI_PORTS - portcount);
return;
}
@@ -831,7 +831,7 @@ static USBDevice *ehci_find_device(EHCIState *ehci, uint8_t addr)
USBPort *port;
int i;
- for (i = 0; i < NB_PORTS; i++) {
+ for (i = 0; i < EHCI_PORTS; i++) {
port = &ehci->ports[i];
if (!(ehci->portsc[i] & PORTSC_PED)) {
DPRINTF("Port %d not enabled\n", i);
@@ -850,7 +850,7 @@ void ehci_reset(void *opaque)
{
EHCIState *s = opaque;
int i;
- USBDevice *devs[NB_PORTS];
+ USBDevice *devs[EHCI_PORTS];
trace_usb_ehci_reset();
@@ -858,7 +858,7 @@ void ehci_reset(void *opaque)
* Do the detach before touching portsc, so that it correctly gets send to
* us or to our companion based on PORTSC_POWNER before the reset.
*/
- for(i = 0; i < NB_PORTS; i++) {
+ for(i = 0; i < EHCI_PORTS; i++) {
devs[i] = s->ports[i].dev;
if (devs[i] && devs[i]->attached) {
usb_detach(&s->ports[i]);
@@ -877,7 +877,7 @@ void ehci_reset(void *opaque)
s->astate = EST_INACTIVE;
s->pstate = EST_INACTIVE;
- for(i = 0; i < NB_PORTS; i++) {
+ for(i = 0; i < EHCI_PORTS; i++) {
if (s->companion_ports[i]) {
s->portsc[i] = PORTSC_POWNER | PORTSC_PPOWER;
} else {
@@ -1086,7 +1086,7 @@ static void ehci_opreg_write(void *ptr, hwaddr addr,
case CONFIGFLAG:
val &= 0x1;
if (val) {
- for (i = 0; i < NB_PORTS; i++) {
+ for (i = 0; i < EHCI_PORTS; i++) {
handle_port_owner_write(s, i, 0);
}
}
@@ -2427,7 +2427,7 @@ static int usb_ehci_post_load(void *opaque, int version_id)
EHCIState *s = opaque;
int i;
- for (i = 0; i < NB_PORTS; i++) {
+ for (i = 0; i < EHCI_PORTS; i++) {
USBPort *companion = s->companion_ports[i];
if (companion == NULL) {
continue;
@@ -2509,9 +2509,9 @@ void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp)
{
int i;
- if (s->portnr > NB_PORTS) {
+ if (s->portnr > EHCI_PORTS) {
error_setg(errp, "Too many ports! Max. port number is %d.",
- NB_PORTS);
+ EHCI_PORTS);
return;
}
if (s->maxframes < 8 || s->maxframes > 512) {
--
2.41.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/3] hw/usb: Rename NB_PORTS -> UHCI_PORTS / EHCI_PORTS
2024-02-13 4:38 [PATCH 0/3] hw/usb: Rename NB_PORTS -> UHCI_PORTS / EHCI_PORTS Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2024-02-13 4:38 ` [PATCH 3/3] hw/usb/ehci: Rename NB_PORTS -> EHCI_PORTS Philippe Mathieu-Daudé
@ 2024-02-13 6:35 ` Richard Henderson
2024-02-13 18:12 ` Michael Tokarev
4 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2024-02-13 6:35 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel; +Cc: qemu-trivial, Gerd Hoffmann
On 2/12/24 18:38, Philippe Mathieu-Daudé wrote:
> Philippe Mathieu-Daudé (3):
> hw/usb: Style cleanup
> hw/usb/uhci: Rename NB_PORTS -> UHCI_PORTS
> hw/usb/ehci: Rename NB_PORTS -> EHCI_PORTS
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/3] hw/usb: Rename NB_PORTS -> UHCI_PORTS / EHCI_PORTS
2024-02-13 4:38 [PATCH 0/3] hw/usb: Rename NB_PORTS -> UHCI_PORTS / EHCI_PORTS Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2024-02-13 6:35 ` [PATCH 0/3] hw/usb: Rename NB_PORTS -> UHCI_PORTS / EHCI_PORTS Richard Henderson
@ 2024-02-13 18:12 ` Michael Tokarev
4 siblings, 0 replies; 6+ messages in thread
From: Michael Tokarev @ 2024-02-13 18:12 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel; +Cc: qemu-trivial, Gerd Hoffmann
13.02.2024 07:38, Philippe Mathieu-Daudé wrote:
> Rename variables to avoid clashing when including both
> "hw/usb/hcd-ehci.h" and "hw/usb/hcd-uhci.h" in the same
> file.
>
> Philippe Mathieu-Daudé (3):
> hw/usb: Style cleanup
> hw/usb/uhci: Rename NB_PORTS -> UHCI_PORTS
> hw/usb/ehci: Rename NB_PORTS -> EHCI_PORTS
Picked up the series for trivial-patches.
Thanks,
/mjt
^ permalink raw reply [flat|nested] 6+ messages in thread