Skip to contentSkip to conversation

usb: use defines instead of magic numbers for USB serial bus release number

PATCH New Brad Hards 1 participant 4 messages Jun 2, 2011

lore
Share & tools
lore

Brad Hards

author
#0 lore raw

cover usb: use defines instead of magic numbers for USB serial bus release number

There is some commonality between the UHCI and EHCI (and xHCI, future) drivers. So we can make nice defines instead of magic numbers.

 usb-ehci.c |    2 +-
 usb-uhci.c |    2 +-
 usb.h      |    6 ++++++
 3 files changed, 8 insertions(+), 2 deletions(-)
author
#1 lore raw

PATCH 1/3 usb: Add defines for USB Serial Bus Release Number register

---
 hw/usb.h |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
hw/usb.h +6 -0
index 9882400..2c051b3 100644
@@ -26,6 +26,12 @@
 #include "qdev.h"
 #include "qemu-queue.h"
 
+/* Constants related to the USB / PCI interaction */
+#define USB_SBRN    0x60 /* Serial Bus Release Number Register */
+#define USB_RELEASE_1  0x10 /* USB 1.0 */
+#define USB_RELEASE_2  0x20 /* USB 2.0 */
+#define USB_RELEASE_3  0x30 /* USB 3.0 */
+
 #define USB_TOKEN_SETUP 0x2d
 #define USB_TOKEN_IN    0x69 /* device -> host */
 #define USB_TOKEN_OUT   0xe1 /* host -> device */
Signature · 1 line
1.7.4.1
author
#2 lore raw

PATCH 2/3 usb: Use defines for serial bus release number register for UHCI

In reply to Brad Hards
---
 hw/usb-uhci.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/usb-uhci.c +1 -1
index c0de05b..d9c86ad 100644
@@ -1098,7 +1098,7 @@ static int usb_uhci_common_initfn(UHCIState *s)
     pci_config_set_class(pci_conf, PCI_CLASS_SERIAL_USB);
     /* TODO: reset value should be 0. */
     pci_conf[PCI_INTERRUPT_PIN] = 4; // interrupt pin 3
-    pci_conf[0x60] = 0x10; // release number
+    pci_conf[USB_SBRN] = USB_RELEASE_1; // release number
 
     usb_bus_new(&s->bus, &s->dev.qdev);
     for(i = 0; i < NB_PORTS; i++) {
Signature · 1 line
1.7.4.1
author
#3 lore raw

PATCH 3/3 usb: Use defines for serial bus release number register for EHCI

In reply to Brad Hards
---
 hw/usb-ehci.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/usb-ehci.c +1 -1
index f63519e..81b9d0b 100644
@@ -1970,7 +1970,7 @@ static int usb_ehci_initfn(PCIDevice *dev)
 
     // pci_conf[0x50] = 0x01; // power management caps
 
-    pci_set_byte(&pci_conf[0x60], 0x20);  // spec release number (2.1.4)
+    pci_set_byte(&pci_conf[USB_SBRN], USB_RELEASE_2); // release number (2.1.4)
     pci_set_byte(&pci_conf[0x61], 0x20);  // frame length adjustment (2.1.5)
     pci_set_word(&pci_conf[0x62], 0x00);  // port wake up capability (2.1.6)
 
Signature · 1 line
1.7.4.1