summaryrefslogtreecommitdiff
path: root/payloads
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2012-11-01 15:44:10 -0700
committerStefan Reinauer <stefan.reinauer@coreboot.org>2012-11-07 18:38:37 +0100
commit93ded5905c36d34c4e4f132623c854bbd895b8c9 (patch)
tree242d35c611db91e2351a4e942ff518a66110ca38 /payloads
parent8670b9b81aba6bf51510e337d4f7208d2b4ea320 (diff)
libpayload: Turn the "debug" #define into the usb_debug static inline function.
The "debug" macro used internally in the libpayload USB subsystem was very generically named and would leak into consumers of the library that included usb.h directly or indirectly. This change turns that #define from a macro into a static inline function to move away from the preprocessor, and also renames it to usb_debug so it's less likely to collide with something unrelated. Change-Id: I18717df111aa9671495f8a2a5bdb2c6311fa7acf Signed-off-by: Gabe Black <gabeblack@google.com> Reviewed-on: http://review.coreboot.org/1738 Reviewed-by: Patrick Georgi <patrick@georgi-clan.de> Tested-by: build bot (Jenkins)
Diffstat (limited to 'payloads')
-rw-r--r--payloads/libpayload/drivers/usb/ehci.c18
-rw-r--r--payloads/libpayload/drivers/usb/ehci_rh.c12
-rw-r--r--payloads/libpayload/drivers/usb/ohci.c18
-rw-r--r--payloads/libpayload/drivers/usb/ohci_rh.c18
-rw-r--r--payloads/libpayload/drivers/usb/quirks.c2
-rw-r--r--payloads/libpayload/drivers/usb/uhci.c46
-rw-r--r--payloads/libpayload/drivers/usb/uhci_rh.c18
-rw-r--r--payloads/libpayload/drivers/usb/usb.c28
-rw-r--r--payloads/libpayload/drivers/usb/usbhid.c18
-rw-r--r--payloads/libpayload/drivers/usb/usbhub.c4
-rw-r--r--payloads/libpayload/drivers/usb/usbmsc.c18
-rw-r--r--payloads/libpayload/drivers/usb/xhci.c36
-rw-r--r--payloads/libpayload/drivers/usb/xhci_rh.c8
-rw-r--r--payloads/libpayload/include/usb/usb.h10
14 files changed, 129 insertions, 125 deletions
diff --git a/payloads/libpayload/drivers/usb/ehci.c b/payloads/libpayload/drivers/usb/ehci.c
index 4d0a209977..29b399a324 100644
--- a/payloads/libpayload/drivers/usb/ehci.c
+++ b/payloads/libpayload/drivers/usb/ehci.c
@@ -34,8 +34,8 @@
static void dump_td(u32 addr)
{
qtd_t *td = phys_to_virt(addr);
- debug("td at phys(%x): status: %x\n\n", addr, td->token & QTD_STATUS_MASK);
- debug("- cerr: %x, total_len: %x\n\n", (td->token & QTD_CERR_MASK) >> QTD_CERR_SHIFT,
+ usb_debug("td at phys(%x): status: %x\n\n", addr, td->token & QTD_STATUS_MASK);
+ usb_debug("- cerr: %x, total_len: %x\n\n", (td->token & QTD_CERR_MASK) >> QTD_CERR_SHIFT,
(td->token & QTD_TOTAL_LEN_MASK) >> QTD_TOTAL_LEN_SHIFT);
}
@@ -70,7 +70,7 @@ static int ehci_set_periodic_schedule(ehci_t *ehcic, int enable)
&& timeout--)
mdelay(1);
if (timeout < 0) {
- debug("ehci periodic schedule status change timed out.\n");
+ usb_debug("ehci periodic schedule status change timed out.\n");
return 1;
}
return 0;
@@ -110,7 +110,7 @@ static int closest_usb2_hub(const usbdev_t *dev, int *const addr, int *const por
*port = usb1dev->port;
return 0;
} else {
- debug("ehci: Couldn't find closest USB2.0 hub.\n");
+ usb_debug("ehci: Couldn't find closest USB2.0 hub.\n");
return 1;
}
}
@@ -192,7 +192,7 @@ static int wait_for_tds(qtd_t *head)
if (cur->token & QTD_HALTED) {
printf("ERROR with packet\n");
dump_td(virt_to_phys(cur));
- debug("-----------------\n");
+ usb_debug("-----------------\n");
return 1;
}
if (cur->next_qtd & 1) {
@@ -200,7 +200,7 @@ static int wait_for_tds(qtd_t *head)
}
if (0) dump_td(virt_to_phys(cur));
/* helps debugging the TD chain */
- if (0) debug("\nmoving from %x to %x\n", cur, phys_to_virt(cur->next_qtd));
+ if (0) usb_debug("\nmoving from %x to %x\n", cur, phys_to_virt(cur->next_qtd));
cur = phys_to_virt(cur->next_qtd);
}
return result;
@@ -222,7 +222,7 @@ static int ehci_set_async_schedule(ehci_t *ehcic, int enable)
&& timeout--)
mdelay(1);
if (timeout < 0) {
- debug("ehci async schedule status change timed out.\n");
+ usb_debug("ehci async schedule status change timed out.\n");
return 1;
}
return 0;
@@ -590,7 +590,7 @@ static u8 *ehci_poll_intr_queue(void *const queue)
if (!(intrq->head->td.token & QTD_STATUS_MASK))
ret = intrq->head->data;
else
- debug("ehci_poll_intr_queue: transfer failed, "
+ usb_debug("ehci_poll_intr_queue: transfer failed, "
"status == 0x%02x\n",
intrq->head->td.token & QTD_STATUS_MASK);
@@ -606,7 +606,7 @@ static u8 *ehci_poll_intr_queue(void *const queue)
}
/* reset queue if we fully processed it after underrun */
else if (intrq->qh.td.next_qtd & QTD_TERMINATE) {
- debug("resetting underrun ehci interrupt queue.\n");
+ usb_debug("resetting underrun ehci interrupt queue.\n");
memset(&intrq->qh.td, 0, sizeof(intrq->qh.td));
intrq->qh.td.next_qtd = virt_to_phys(&intrq->head->td);
}
diff --git a/payloads/libpayload/drivers/usb/ehci_rh.c b/payloads/libpayload/drivers/usb/ehci_rh.c
index 5f92bd7894..f58e1cf36c 100644
--- a/payloads/libpayload/drivers/usb/ehci_rh.c
+++ b/payloads/libpayload/drivers/usb/ehci_rh.c
@@ -53,7 +53,7 @@ ehci_rh_destroy (usbdev_t *dev)
static void
ehci_rh_hand_over_port (usbdev_t *dev, int port)
{
- debug("giving up port %x, it's USB1\n", port+1);
+ usb_debug("giving up port %x, it's USB1\n", port+1);
/* Clear ConnectStatusChange before evaluation */
/* RW/C register, so clear it by writing 1 */
@@ -67,7 +67,7 @@ ehci_rh_hand_over_port (usbdev_t *dev, int port)
while (!(RH_INST(dev)->ports[port] & P_CONN_STATUS_CHANGE) && timeout--)
mdelay(10);
if (!(RH_INST(dev)->ports[port] & P_CONN_STATUS_CHANGE)) {
- debug("Warning: Handing port over to companion timed out.\n");
+ usb_debug("Warning: Handing port over to companion timed out.\n");
}
/* RW/C register, so clear it by writing 1 */
@@ -79,7 +79,7 @@ static void
ehci_rh_scanport (usbdev_t *dev, int port)
{
if (RH_INST(dev)->devices[port]!=-1) {
- debug("Unregister device at port %x\n", port+1);
+ usb_debug("Unregister device at port %x\n", port+1);
usb_detach_device(dev->controller, RH_INST(dev)->devices[port]);
RH_INST(dev)->devices[port]=-1;
}
@@ -118,7 +118,7 @@ ehci_rh_scanport (usbdev_t *dev, int port)
ehci_rh_hand_over_port(dev, port);
return;
}
- debug("port %x hosts a USB2 device\n", port+1);
+ usb_debug("port %x hosts a USB2 device\n", port+1);
RH_INST(dev)->devices[port] = usb_attach_device(dev->controller, dev->address, port, 2);
}
/* RW/C register, so clear it by writing 1 */
@@ -157,14 +157,14 @@ ehci_rh_init (usbdev_t *dev)
RH_INST(dev)->n_ports = EHCI_INST(dev->controller)->capabilities->hcsparams & HCS_NPORTS_MASK;
RH_INST(dev)->ports = EHCI_INST(dev->controller)->operation->portsc;
- debug("root hub has %x ports\n", RH_INST(dev)->n_ports);
+ usb_debug("root hub has %x ports\n", RH_INST(dev)->n_ports);
/* If the host controller has port power control, enable power on
* all ports and wait 20ms.
*/
if (EHCI_INST(dev->controller)->capabilities->hcsparams
& HCS_PORT_POWER_CONTROL) {
- debug("host controller has port power control, "
+ usb_debug("host controller has port power control, "
"giving power to all ports.\n");
for (i=0; i < RH_INST(dev)->n_ports; i++)
RH_INST(dev)->ports[i] |= P_PP;
diff --git a/payloads/libpayload/drivers/usb/ohci.c b/payloads/libpayload/drivers/usb/ohci.c
index 570851559e..095eec93b0 100644
--- a/payloads/libpayload/drivers/usb/ohci.c
+++ b/payloads/libpayload/drivers/usb/ohci.c
@@ -206,9 +206,9 @@ dump_td(td_t *cur, int level)
#ifdef USB_DEBUG
static const char *spaces=" ";
const char *spc=spaces+(10-level);
- debug("%std at %x (%s), condition code: %s\n", spc, cur, direction[(cur->config & TD_DIRECTION_MASK) >> TD_DIRECTION_SHIFT],
+ usb_debug("%std at %x (%s), condition code: %s\n", spc, cur, direction[(cur->config & TD_DIRECTION_MASK) >> TD_DIRECTION_SHIFT],
completion_codes[(cur->config & TD_CC_MASK) >> TD_CC_SHIFT]);
- debug("%s toggle: %x\n", spc, !!(cur->config & TD_TOGGLE_DATA1));
+ usb_debug("%s toggle: %x\n", spc, !!(cur->config & TD_TOGGLE_DATA1));
#endif
}
@@ -227,7 +227,7 @@ wait_for_ed(usbdev_t *dev, ed_t *head, int pages)
timeout--) {
/* don't log every ms */
if (!(timeout % 100))
- debug("intst: %x; ctrl: %x; cmdst: %x; head: %x -> %x, tail: %x, condition: %x\n",
+ usb_debug("intst: %x; ctrl: %x; cmdst: %x; head: %x -> %x, tail: %x, condition: %x\n",
OHCI_INST(dev->controller)->opreg->HcInterruptStatus,
OHCI_INST(dev->controller)->opreg->HcControl,
OHCI_INST(dev->controller)->opreg->HcCommandStatus,
@@ -244,7 +244,7 @@ wait_for_ed(usbdev_t *dev, ed_t *head, int pages)
ohci_process_done_queue(OHCI_INST(dev->controller), 1);
if (head->head_pointer & 1) {
- debug("HALTED!\n");
+ usb_debug("HALTED!\n");
return 1;
}
return 0;
@@ -363,7 +363,7 @@ ohci_control (usbdev_t *dev, direction_t dir, int drlen, void *devreq, int dalen
head->tail_pointer = virt_to_phys(final_td);
head->head_pointer = virt_to_phys(first_td);
- debug("doing control transfer with %x. first_td at %x\n",
+ usb_debug("doing control transfer with %x. first_td at %x\n",
head->config & ED_FUNC_MASK, virt_to_phys(first_td));
/* activate schedule */
@@ -389,7 +389,7 @@ static int
ohci_bulk (endpoint_t *ep, int dalen, u8 *data, int finalize)
{
int i;
- debug("bulk: %x bytes from %x, finalize: %x, maxpacketsize: %x\n", dalen, data, finalize, ep->maxpacketsize);
+ usb_debug("bulk: %x bytes from %x, finalize: %x, maxpacketsize: %x\n", dalen, data, finalize, ep->maxpacketsize);
td_t *cur, *next;
@@ -465,7 +465,7 @@ ohci_bulk (endpoint_t *ep, int dalen, u8 *data, int finalize)
head->tail_pointer = virt_to_phys(cur);
head->head_pointer = virt_to_phys(first_td) | (ep->toggle?ED_TOGGLE:0);
- debug("doing bulk transfer with %x(%x). first_td at %x, last %x\n",
+ usb_debug("doing bulk transfer with %x(%x). first_td at %x, last %x\n",
head->config & ED_FUNC_MASK,
(head->config & ED_EP_MASK) >> ED_EP_SHIFT,
virt_to_phys(first_td), virt_to_phys(cur));
@@ -738,7 +738,7 @@ ohci_process_done_queue(ohci_t *const ohci, const int spew_debug)
++i;
}
if (spew_debug)
- debug("Processed %d done TDs.\n", i);
+ usb_debug("Processed %d done TDs.\n", i);
j = 0;
/* Process interrupt queue TDs in right order. */
@@ -763,6 +763,6 @@ ohci_process_done_queue(ohci_t *const ohci, const int spew_debug)
++j;
}
if (spew_debug)
- debug("processed %d done tds, %d intr tds thereof.\n", i, j);
+ usb_debug("processed %d done tds, %d intr tds thereof.\n", i, j);
}
diff --git a/payloads/libpayload/drivers/usb/ohci_rh.c b/payloads/libpayload/drivers/usb/ohci_rh.c
index ac92f45a46..eb3e10b26c 100644
--- a/payloads/libpayload/drivers/usb/ohci_rh.c
+++ b/payloads/libpayload/drivers/usb/ohci_rh.c
@@ -65,17 +65,17 @@ ohci_rh_enable_port (usbdev_t *dev, int port)
}
if (OHCI_INST (dev->controller)->opreg->HcRhPortStatus[port]
& PortResetStatus) {
- debug("Warning: root-hub port reset timed out.\n");
+ usb_debug("Warning: root-hub port reset timed out.\n");
break;
}
if ((200-timeout) < 20)
- debug("Warning: port reset too short: %dms; "
+ usb_debug("Warning: port reset too short: %dms; "
"should be at least 10ms.\n",
(200-timeout)/2);
/* clear reset status change */
OHCI_INST (dev->controller)->opreg->HcRhPortStatus[port] =
PortResetStatusChange;
- debug ("rh port reset finished after %dms.\n", (200-timeout)/2);
+ usb_debug ("rh port reset finished after %dms.\n", (200-timeout)/2);
}
}
@@ -96,7 +96,7 @@ static void
ohci_rh_scanport (usbdev_t *dev, int port)
{
if (port >= RH_INST(dev)->numports) {
- debug("Invalid port %d\n", port);
+ usb_debug("Invalid port %d\n", port);
return;
}
@@ -117,7 +117,7 @@ ohci_rh_scanport (usbdev_t *dev, int port)
mdelay(100); // wait for signal to stabilize
if (!(OHCI_INST(dev->controller)->opreg->HcRhPortStatus[port] & PortEnableStatus)) {
- debug ("port enable failed\n");
+ usb_debug ("port enable failed\n");
return;
}
@@ -132,12 +132,12 @@ ohci_rh_report_port_changes (usbdev_t *dev)
if (!(OHCI_INST (dev->controller)->opreg->HcInterruptStatus & RootHubStatusChange)) return -1;
OHCI_INST (dev->controller)->opreg->HcInterruptStatus = RootHubStatusChange;
- debug("port change\n");
+ usb_debug("port change\n");
for (i = 0; i < RH_INST(dev)->numports; i++) {
// maybe detach+attach happened between two scans?
if (OHCI_INST (dev->controller)->opreg->HcRhPortStatus[i] & ConnectStatusChange) {
- debug("attachment change on port %d\n", i);
+ usb_debug("attachment change on port %d\n", i);
return i;
}
}
@@ -177,7 +177,7 @@ ohci_rh_init (usbdev_t *dev)
RH_INST (dev)->numports = OHCI_INST (dev->controller)->opreg->HcRhDescriptorA & NumberDownstreamPortsMask;
RH_INST (dev)->port = malloc(sizeof(int) * RH_INST (dev)->numports);
- debug("%d ports registered\n", RH_INST (dev)->numports);
+ usb_debug("%d ports registered\n", RH_INST (dev)->numports);
for (i = 0; i < RH_INST (dev)->numports; i++) {
ohci_rh_enable_port (dev, i);
@@ -190,5 +190,5 @@ ohci_rh_init (usbdev_t *dev)
dev->hub = -1;
dev->port = -1;
- debug("rh init done\n");
+ usb_debug("rh init done\n");
}
diff --git a/payloads/libpayload/drivers/usb/quirks.c b/payloads/libpayload/drivers/usb/quirks.c
index 96acd082ea..a8f2622e31 100644
--- a/payloads/libpayload/drivers/usb/quirks.c
+++ b/payloads/libpayload/drivers/usb/quirks.c
@@ -64,7 +64,7 @@ u32 usb_quirk_check(u16 vendor, u16 device)
for (i = 0; i < ARRAY_SIZE(usb_quirks); i++) {
if ((usb_quirks[i].vendor == vendor) &&
(usb_quirks[i].device == device)) {
- debug("USB quirks enabled: %08x\n",
+ usb_debug("USB quirks enabled: %08x\n",
usb_quirks[i].quirks);
return usb_quirks[i].quirks;
}
diff --git a/payloads/libpayload/drivers/usb/uhci.c b/payloads/libpayload/drivers/usb/uhci.c
index 764770763a..ab4f7982d1 100644
--- a/payloads/libpayload/drivers/usb/uhci.c
+++ b/payloads/libpayload/drivers/usb/uhci.c
@@ -50,14 +50,14 @@ static u8* uhci_poll_intr_queue (void *queue);
static void
uhci_dump (hci_t *controller)
{
- debug ("dump:\nUSBCMD: %x\n", uhci_reg_read16 (controller, USBCMD));
- debug ("USBSTS: %x\n", uhci_reg_read16 (controller, USBSTS));
- debug ("USBINTR: %x\n", uhci_reg_read16 (controller, USBINTR));
- debug ("FRNUM: %x\n", uhci_reg_read16 (controller, FRNUM));
- debug ("FLBASEADD: %x\n", uhci_reg_read32 (controller, FLBASEADD));
- debug ("SOFMOD: %x\n", uhci_reg_read8 (controller, SOFMOD));
- debug ("PORTSC1: %x\n", uhci_reg_read16 (controller, PORTSC1));
- debug ("PORTSC2: %x\n", uhci_reg_read16 (controller, PORTSC2));
+ usb_debug ("dump:\nUSBCMD: %x\n", uhci_reg_read16 (controller, USBCMD));
+ usb_debug ("USBSTS: %x\n", uhci_reg_read16 (controller, USBSTS));
+ usb_debug ("USBINTR: %x\n", uhci_reg_read16 (controller, USBINTR));
+ usb_debug ("FRNUM: %x\n", uhci_reg_read16 (controller, FRNUM));
+ usb_debug ("FLBASEADD: %x\n", uhci_reg_read32 (controller, FLBASEADD));
+ usb_debug ("SOFMOD: %x\n", uhci_reg_read8 (controller, SOFMOD));
+ usb_debug ("PORTSC1: %x\n", uhci_reg_read16 (controller, PORTSC1));
+ usb_debug ("PORTSC2: %x\n", uhci_reg_read16 (controller, PORTSC2));
}
#endif
@@ -80,22 +80,22 @@ td_dump (td_t *td)
sprintf(td_value, "%x", td->token & TD_PID_MASK);
td_type=td_value;
}
- debug ("%s packet (at %lx) to %x.%x failed\n", td_type,
+ usb_debug ("%s packet (at %lx) to %x.%x failed\n", td_type,
virt_to_phys (td), (td->token & TD_DEVADDR_MASK) >> TD_DEVADDR_SHIFT,
(td->token & TD_EP_MASK) >> TD_EP_SHIFT);
- debug ("td (counter at %x) returns: ", td->ctrlsts >> TD_COUNTER_SHIFT);
- debug (" bitstuff err: %x, ", !!(td->ctrlsts & TD_STATUS_BITSTUFF_ERR));
- debug (" CRC err: %x, ", !!(td->ctrlsts & TD_STATUS_CRC_ERR));
- debug (" NAK rcvd: %x, ", !!(td->ctrlsts & TD_STATUS_NAK_RCVD));
- debug (" Babble: %x, ", !!(td->ctrlsts & TD_STATUS_BABBLE));
- debug (" Data Buffer err: %x, ", !!(td->ctrlsts & TD_STATUS_DATABUF_ERR));
- debug (" Stalled: %x, ", !!(td->ctrlsts & TD_STATUS_STALLED));
- debug (" Active: %x\n", !!(td->ctrlsts & TD_STATUS_ACTIVE));
+ usb_debug ("td (counter at %x) returns: ", td->ctrlsts >> TD_COUNTER_SHIFT);
+ usb_debug (" bitstuff err: %x, ", !!(td->ctrlsts & TD_STATUS_BITSTUFF_ERR));
+ usb_debug (" CRC err: %x, ", !!(td->ctrlsts & TD_STATUS_CRC_ERR));
+ usb_debug (" NAK rcvd: %x, ", !!(td->ctrlsts & TD_STATUS_NAK_RCVD));
+ usb_debug (" Babble: %x, ", !!(td->ctrlsts & TD_STATUS_BABBLE));
+ usb_debug (" Data Buffer err: %x, ", !!(td->ctrlsts & TD_STATUS_DATABUF_ERR));
+ usb_debug (" Stalled: %x, ", !!(td->ctrlsts & TD_STATUS_STALLED));
+ usb_debug (" Active: %x\n", !!(td->ctrlsts & TD_STATUS_ACTIVE));
if (td->ctrlsts & TD_STATUS_BABBLE)
- debug (" Babble because of %s\n",
+ usb_debug (" Babble because of %s\n",
(td->ctrlsts & TD_STATUS_BITSTUFF_ERR) ? "host" : "device");
if (td->ctrlsts & TD_STATUS_ACTIVE)
- debug (" still active - timeout?\n");
+ usb_debug (" still active - timeout?\n");
}
static void
@@ -113,12 +113,12 @@ uhci_reset (hci_t *controller)
while (((uhci_reg_read16 (controller, USBCMD) & 2) != 0) && timeout--)
udelay (500);
if (timeout < 0)
- debug ("Warning: uhci: host controller reset timed out.\n");
+ usb_debug ("Warning: uhci: host controller reset timed out.\n");
uhci_reg_write32 (controller, FLBASEADD,
(u32) virt_to_phys (UHCI_INST (controller)->
framelistptr));
- //debug ("framelist at %p\n",UHCI_INST(controller)->framelistptr);
+ //usb_debug ("framelist at %p\n",UHCI_INST(controller)->framelistptr);
/* disable irqs */
uhci_reg_write16 (controller, USBINTR, 0);
@@ -364,7 +364,7 @@ uhci_control (usbdev_t *dev, direction_t dir, int drlen, void *devreq, int dalen
if (td == 0) {
result = 0;
} else {
- debug ("control packet, req %x\n", req);
+ usb_debug ("control packet, req %x\n", req);
td_dump (td);
result = 1;
}
@@ -445,7 +445,7 @@ uhci_bulk (endpoint_t *ep, int size, u8 *data, int finalize)
size -= maxpsize;
}
if (run_schedule (ep->dev, tds) == 1) {
- debug("Stalled. Trying to clean up.\n");
+ usb_debug("Stalled. Trying to clean up.\n");
clear_stall (ep);
free (tds);
return 1;
diff --git a/payloads/libpayload/drivers/usb/uhci_rh.c b/payloads/libpayload/drivers/usb/uhci_rh.c
index 547f0644b4..44ba498274 100644
--- a/payloads/libpayload/drivers/usb/uhci_rh.c
+++ b/payloads/libpayload/drivers/usb/uhci_rh.c
@@ -49,7 +49,7 @@ uhci_rh_enable_port (usbdev_t *dev, int port)
else if (port == 2)
port = PORTSC2;
else {
- debug("Invalid port %d\n", port);
+ usb_debug("Invalid port %d\n", port);
return;
}
@@ -73,7 +73,7 @@ uhci_rh_enable_port (usbdev_t *dev, int port)
udelay(500); timeout--;
} while (((value & (1 << 2)) == 0) && (value & 0x01) && timeout);
if (!timeout)
- debug("Warning: uhci_rh: port enabling timed out.\n");
+ usb_debug("Warning: uhci_rh: port enabling timed out.\n");
}
/* disable root hub */
@@ -86,7 +86,7 @@ uhci_rh_disable_port (usbdev_t *dev, int port)
else if (port == 2)
port = PORTSC2;
else {
- debug("Invalid port %d\n", port);
+ usb_debug("Invalid port %d\n", port);
return;
}
uhci_reg_write16(controller, port,
@@ -100,7 +100,7 @@ uhci_rh_disable_port (usbdev_t *dev, int port)
udelay(500); timeout--;
} while (((value & (1 << 2)) != 0) && timeout);
if (!timeout)
- debug("Warning: uhci_rh: port disabling timed out.\n");
+ usb_debug("Warning: uhci_rh: port disabling timed out.\n");
}
static void
@@ -114,7 +114,7 @@ uhci_rh_scanport (usbdev_t *dev, int port)
portsc = PORTSC2;
offset = 1;
} else {
- debug("Invalid port %d\n", port);
+ usb_debug("Invalid port %d\n", port);
return;
}
int devno = RH_INST (dev)->port[offset];
@@ -147,25 +147,25 @@ uhci_rh_report_port_changes (usbdev_t *dev)
stored = (RH_INST (dev)->port[0] == -1);
real = ((uhci_reg_read16 (dev->controller, PORTSC1) & 1) == 0);
if (stored != real) {
- debug("change on port 1\n");
+ usb_debug("change on port 1\n");
return 1;
}
stored = (RH_INST (dev)->port[1] == -1);
real = ((uhci_reg_read16 (dev->controller, PORTSC2) & 1) == 0);
if (stored != real) {
- debug("change on port 2\n");
+ usb_debug("change on port 2\n");
return 2;
}
// maybe detach+attach happened between two scans?
if ((uhci_reg_read16 (dev->controller, PORTSC1) & 2) > 0) {
- debug("possibly re-attached on port 1\n");
+ usb_debug("possibly re-attached on port 1\n");
return 1;
}
if ((uhci_reg_read16 (dev->controller, PORTSC2) & 2) > 0) {
- debug("possibly re-attached on port 2\n");
+ usb_debug("possibly re-attached on port 2\n");
return 2;
}
diff --git a/payloads/libpayload/drivers/usb/usb.c b/payloads/libpayload/drivers/usb/usb.c
index d5514f980c..e51adaca7f 100644
--- a/payloads/libpayload/drivers/usb/usb.c
+++ b/payloads/libpayload/drivers/usb/usb.c
@@ -108,7 +108,7 @@ void
init_device_entry (hci_t *controller, int i)
{
if (controller->devices[i] != 0)
- debug("warning: device %d reassigned?\n", i);
+ usb_debug("warning: device %d reassigned?\n", i);
controller->devices[i] = malloc(sizeof(usbdev_t));
controller->devices[i]->controller = controller;
controller->devices[i]->address = -1;
@@ -162,13 +162,13 @@ get_descriptor (usbdev_t *dev, unsigned char bmRequestType, int descType,
dr.wIndex = langID;
dr.wLength = 8;
if (dev->controller->control (dev, IN, sizeof (dr), &dr, 8, buf)) {
- debug ("getting descriptor size (type %x) failed\n",
+ usb_debug ("getting descriptor size (type %x) failed\n",
descType);
}
if (descType == 1) {
device_descriptor_t *dd = (device_descriptor_t *) buf;
- debug ("maxPacketSize0: %x\n", dd->bMaxPacketSize0);
+ usb_debug ("maxPacketSize0: %x\n", dd->bMaxPacketSize0);
if (dd->bMaxPacketSize0 != 0)
dev->endpoints[0].maxpacketsize = dd->bMaxPacketSize0;
}
@@ -186,7 +186,7 @@ get_descriptor (usbdev_t *dev, unsigned char bmRequestType, int descType,
dr.wLength = size;
if (dev->controller->
control (dev, IN, sizeof (dr), &dr, size, result)) {
- debug ("getting descriptor (type %x, size %x) failed\n",
+ usb_debug ("getting descriptor (type %x, size %x) failed\n",
descType, size);
}
@@ -242,7 +242,7 @@ get_free_address (hci_t *controller)
if (controller->devices[i] == 0)
return i;
}
- debug ("no free address found\n");
+ usb_debug ("no free address found\n");
return -1; // no free address
}
@@ -277,7 +277,7 @@ set_address (hci_t *controller, int speed, int hubport, int hubaddr)
dev->endpoints[0].direction = SETUP;
mdelay (50);
if (dev->controller->control (dev, OUT, sizeof (dr), &dr, 0, 0)) {
- debug ("set_address failed\n");
+ usb_debug ("set_address failed\n");
return -1;
}
mdelay (50);
@@ -291,7 +291,7 @@ set_address (hci_t *controller, int speed, int hubport, int hubaddr)
dd->bcdUSB >> 8, dd->bcdUSB & 0xff);
dev->quirks = usb_quirk_check(dd->idVendor, dd->idProduct);
- debug ("\ndevice has %x configurations\n", dd->bNumConfigurations);
+ usb_debug ("\ndevice has %x configurations\n", dd->bNumConfigurations);
if (dd->bNumConfigurations == 0) {
/* device isn't usable */
printf ("... no usable configuration!\n");
@@ -309,7 +309,7 @@ set_address (hci_t *controller, int speed, int hubport, int hubaddr)
int i;
int num = cd->bNumInterfaces;
interface_descriptor_t *current = interface;
- debug ("device has %x interfaces\n", num);
+ usb_debug ("device has %x interfaces\n", num);
if (num > 1) {
int interfaces = usb_interface_check(dd->idVendor, dd->idProduct);
if (interfaces) {
@@ -331,7 +331,7 @@ set_address (hci_t *controller, int speed, int hubport, int hubaddr)
}
for (i = 0; i < num; i++) {
int j;
- debug (" #%x has %x endpoints, interface %x:%x, protocol %x\n",
+ usb_debug (" #%x has %x endpoints, interface %x:%x, protocol %x\n",
current->bInterfaceNumber, current->bNumEndpoints, current->bInterfaceClass, current->bInterfaceSubClass, current->bInterfaceProtocol);
endpoint_descriptor_t *endp =
(endpoint_descriptor_t *) (((char *) current)
@@ -349,7 +349,7 @@ set_address (hci_t *controller, int speed, int hubport, int hubaddr)
static const char *transfertypes[4] = {
"control", "isochronous", "bulk", "interrupt"
};
- debug (" #%x: Endpoint %x (%s), max packet size %x, type %s\n", j, endp->bEndpointAddress & 0x7f, ((endp->bEndpointAddress & 0x80) != 0) ? "in" : "out", endp->wMaxPacketSize, transfertypes[endp->bmAttributes]);
+ usb_debug (" #%x: Endpoint %x (%s), max packet size %x, type %s\n", j, endp->bEndpointAddress & 0x7f, ((endp->bEndpointAddress & 0x80) != 0) ? "in" : "out", endp->wMaxPacketSize, transfertypes[endp->bmAttributes]);
#endif
endpoint_t *ep =
&dev->endpoints[dev->num_endp++];
@@ -403,7 +403,7 @@ set_address (hci_t *controller, int speed, int hubport, int hubaddr)
#ifdef CONFIG_USB_HID
controller->devices[adr]->init = usb_hid_init;
#else
- debug ("NOTICE: USB HID support not compiled in\n");
+ usb_debug ("NOTICE: USB HID support not compiled in\n");
#endif
break;
case physical_device:
@@ -420,7 +420,7 @@ set_address (hci_t *controller, int speed, int hubport, int hubaddr)
#ifdef CONFIG_USB_MSC
controller->devices[adr]->init = usb_msc_init;
#else
- debug ("NOTICE: USB MSC support not compiled in\n");
+ usb_debug ("NOTICE: USB MSC support not compiled in\n");
#endif
break;
case hub_device:
@@ -428,7 +428,7 @@ set_address (hci_t *controller, int speed, int hubport, int hubaddr)
#ifdef CONFIG_USB_HUB
controller->devices[adr]->init = usb_hub_init;
#else
- debug ("NOTICE: USB hub support not compiled in.\n");
+ usb_debug ("NOTICE: USB hub support not compiled in.\n");
#endif
break;
case cdc_device:
@@ -480,7 +480,7 @@ int
usb_attach_device(hci_t *controller, int hubaddress, int port, int speed)
{
static const char* speeds[] = { "full", "low", "high" };
- debug ("%sspeed device\n", (speed <= 2) ? speeds[speed] : "invalid value - no");
+ usb_debug ("%sspeed device\n", (speed <= 2) ? speeds[speed] : "invalid value - no");
int newdev = set_address (controller, speed, port, hubaddress);
if (newdev == -1)
return -1;
diff --git a/payloads/libpayload/drivers/usb/usbhid.c b/payloads/libpayload/drivers/usb/usbhid.c
index d5141c6353..496fbaa3f7 100644
--- a/payloads/libpayload/drivers/usb/usbhid.c
+++ b/payloads/libpayload/drivers/usb/usbhid.c
@@ -324,7 +324,7 @@ usb_hid_process_keyboard_event(usb_hid_keyboard_event_t *current,
if (keypress == -1) {
/* Debug: Print unknown keys */
- debug ("usbhid: <%x> %x [ %x %x %x %x %x %x ] %d\n",
+ usb_debug ("usbhid: <%x> %x [ %x %x %x %x %x %x ] %d\n",
current->modifiers, current->repeats,
current->keys[0], current->keys[1],
current->keys[2], current->keys[3],
@@ -429,18 +429,18 @@ usb_hid_init (usbdev_t *dev)
if (interface->bInterfaceSubClass == hid_subclass_boot) {
u8 countrycode;
- debug (" supports boot interface..\n");
- debug (" it's a %s\n",
+ usb_debug (" supports boot interface..\n");
+ usb_debug (" it's a %s\n",
boot_protos[interface->bInterfaceProtocol]);
switch (interface->bInterfaceProtocol) {
case hid_boot_proto_keyboard:
dev->data = malloc (sizeof (usbhid_inst_t));
if (!dev->data)
fatal("Not enough memory for USB HID device.\n");
- debug (" configuring...\n");
+ usb_debug (" configuring...\n");
usb_hid_set_protocol(dev, interface, hid_proto_boot);
usb_hid_set_idle(dev, interface, KEYBOARD_REPEAT_MS);
- debug (" activating...\n");
+ usb_debug (" activating...\n");
HID_INST (dev)->descriptor =
(hid_descriptor_t *)
@@ -451,7 +451,7 @@ usb_hid_init (usbdev_t *dev)
/* 35 countries defined: */
if (countrycode > 35)
countrycode = 0;
- debug (" Keyboard has %s layout (country code %02x)\n",
+ usb_debug (" Keyboard has %s layout (country code %02x)\n",
countries[countrycode][0], countrycode);
/* Set keyboard layout accordingly */
@@ -470,14 +470,14 @@ usb_hid_init (usbdev_t *dev)
continue;
break;
}
- debug (" found endpoint %x for interrupt-in\n", i);
+ usb_debug (" found endpoint %x for interrupt-in\n", i);
/* 20 buffers of 8 bytes, for every 10 msecs */
HID_INST(dev)->queue = dev->controller->create_intr_queue (&dev->endpoints[i], 8, 20, 10);
keycount = 0;
- debug (" configuration done.\n");
+ usb_debug (" configuration done.\n");
break;
case hid_boot_proto_mouse:
- debug("NOTICE: USB mice are not supported.\n");
+ usb_debug("NOTICE: USB mice are not supported.\n");
break;
}
}
diff --git a/payloads/libpayload/drivers/usb/usbhub.c b/payloads/libpayload/drivers/usb/usbhub.c
index 09ab9ccb29..47215fcf10 100644
--- a/payloads/libpayload/drivers/usb/usbhub.c
+++ b/payloads/libpayload/drivers/usb/usbhub.c
@@ -97,7 +97,7 @@ usb_hub_scanport (usbdev_t *dev, int port)
mdelay(1); timeout--;
} while ((buf[0] & PORT_RESET) && timeout);
if (!timeout)
- debug("Warning: usbhub: port reset timed out.\n");
+ usb_debug("Warning: usbhub: port reset timed out.\n");
/* wait for port to be enabled. the hub is responsible for this */
timeout = 500; /* time out after 500ms */
@@ -106,7 +106,7 @@ usb_hub_scanport (usbdev_t *dev, int port)
mdelay(1); timeout--;
} while (!(buf[0] & PORT_ENABLE) && timeout);
if (!timeout)
- debug("Warning: usbhub: port enabling timed out.\n");
+ usb_debug("Warning: usbhub: port enabling timed out.\n");
get_status (dev, port, DR_PORT, 4, buf);
/* bit 10 9
diff --git a/payloads/libpayload/drivers/usb/usbmsc.c b/payloads/libpayload/drivers/usb/usbmsc.c
index ac1284129b..db369f7bd1 100644
--- a/payloads/libpayload/drivers/usb/usbmsc.c
+++ b/payloads/libpayload/drivers/usb/usbmsc.c
@@ -381,7 +381,7 @@ read_capacity (usbdev_t *dev)
cb.command = 0x25; // read capacity
u8 buf[8];
- debug ("Reading capacity of mass storage device.\n");
+ usb_debug ("Reading capacity of mass storage device.\n");
int count = 0, ret;
while (count++ < 20) {
switch (ret = execute_command
@@ -430,9 +430,9 @@ usb_msc_init (usbdev_t *dev)
interface_descriptor_t *interface =
(interface_descriptor_t *) (((char *) cd) + cd->bLength);
- debug (" it uses %s command set\n",
+ usb_debug (" it uses %s command set\n",
msc_subclass_strings[interface->bInterfaceSubClass]);
- debug (" it uses %s protocol\n",
+ usb_debug (" it uses %s protocol\n",
msc_protocol_strings[interface->bInterfaceProtocol]);
@@ -479,11 +479,11 @@ usb_msc_init (usbdev_t *dev)
printf("couldn't find bulk-out endpoint");
return;
}
- debug (" using endpoint %x as in, %x as out\n",
+ usb_debug (" using endpoint %x as in, %x as out\n",
MSC_INST (dev)->bulk_in->endpoint,
MSC_INST (dev)->bulk_out->endpoint);
- debug (" has %d luns\n", get_max_luns (dev) + 1);
+ usb_debug (" has %d luns\n", get_max_luns (dev) + 1);
printf (" Waiting for device to become ready...");
timeout = 30 * 10; /* SCSI/ATA specs say we have to wait up to 30s. Ugh */
@@ -507,12 +507,12 @@ usb_msc_init (usbdev_t *dev)
printf ("ok.\n");
}
- debug (" spin up");
+ usb_debug (" spin up");
for (i = 0; i < 30; i++) {
- debug (".");
+ usb_debug (".");
switch (spin_up (dev)) {
case MSC_COMMAND_OK:
- debug (" OK.");
+ usb_debug (" OK.");
break;
case MSC_COMMAND_FAIL:
mdelay (100);
@@ -522,7 +522,7 @@ usb_msc_init (usbdev_t *dev)
}
break;
}
- debug ("\n");
+ usb_debug ("\n");
if ((read_capacity (dev) == MSC_COMMAND_OK) && usbdisk_create) {
usbdisk_create (dev);
diff --git a/payloads/libpayload/drivers/usb/xhci.c b/payloads/libpayload/drivers/usb/xhci.c
index 828e0eaec7..f784686b69 100644
--- a/payloads/libpayload/drivers/usb/xhci.c
+++ b/payloads/libpayload/drivers/usb/xhci.c
@@ -86,27 +86,27 @@ xhci_init (pcidev_t addr)
if (pci_read_config32 (controller->bus_address, 0x14) > 0) {
fatal("We don't do 64bit addressing.\n");
}
- debug("regbase: %lx\n", controller->reg_base);
+ usb_debug("regbase: %lx\n", controller->reg_base);
XHCI_INST (controller)->capreg = (void*)controller->reg_base;
XHCI_INST (controller)->opreg = (void*)(controller->reg_base + XHCI_INST (controller)->capreg->caplength);
XHCI_INST (controller)->hcrreg = (void*)(controller->reg_base + XHCI_INST (controller)->capreg->rtsoff);
XHCI_INST (controller)->dbreg = (void*)(controller->reg_base + XHCI_INST (controller)->capreg->dboff);
- debug("caplen: %lx\nrtsoff: %lx\ndboff: %lx\n", XHCI_INST (controller)->capreg->caplength, XHCI_INST (controller)->capreg->rtsoff, XHCI_INST (controller)->capreg->dboff);
- debug("caplength: %x\n", XHCI_INST (controller)->capreg->caplength);
- debug("hciversion: %x.%x\n", XHCI_INST (controller)->capreg->hciver_hi, XHCI_INST (controller)->capreg->hciver_lo);
+ usb_debug("caplen: %lx\nrtsoff: %lx\ndboff: %lx\n", XHCI_INST (controller)->capreg->caplength, XHCI_INST (controller)->capreg->rtsoff, XHCI_INST (controller)->capreg->dboff);
+ usb_debug("caplength: %x\n", XHCI_INST (controller)->capreg->caplength);
+ usb_debug("hciversion: %x.%x\n", XHCI_INST (controller)->capreg->hciver_hi, XHCI_INST (controller)->capreg->hciver_lo);
if ((XHCI_INST (controller)->capreg->hciversion < 0x96) || (XHCI_INST (controller)->capreg->hciversion > 0x100)) {
fatal("Unsupported xHCI version\n");
}
- debug("maxslots: %x\n", XHCI_INST (controller)->capreg->MaxSlots);
- debug("maxports: %x\n", XHCI_INST (controller)->capreg->MaxPorts);
+ usb_debug("maxslots: %x\n", XHCI_INST (controller)->capreg->MaxSlots);
+ usb_debug("maxports: %x\n", XHCI_INST (controller)->capreg->MaxPorts);
int pagesize = XHCI_INST (controller)->opreg->pagesize << 12;
- debug("pagesize: %x\n", pagesize);
+ usb_debug("pagesize: %x\n", pagesize);
XHCI_INST (controller)->dcbaa = memalign(64, (XHCI_INST (controller)->capreg->MaxSlots+1)*sizeof(devctxp_t));
memset((void*)XHCI_INST (controller)->dcbaa, 0, (XHCI_INST (controller)->capreg->MaxSlots+1)*sizeof(devctxp_t));
- debug("max scratchpad bufs: %x\n", XHCI_INST (controller)->capreg->Max_Scratchpad_Bufs);
+ usb_debug("max scratchpad bufs: %x\n", XHCI_INST (controller)->capreg->Max_Scratchpad_Bufs);
if (XHCI_INST (controller)->capreg->Max_Scratchpad_Bufs > 0) {
XHCI_INST (controller)->dcbaa->ptr = memalign(64, XHCI_INST (controller)->capreg->Max_Scratchpad_Bufs * 8);
}
@@ -118,7 +118,7 @@ xhci_init (pcidev_t addr)
while ((XHCI_INST (controller)->opreg->usbsts & USBSTS_CNR) != 0) mdelay(1);
printf("ok.\n");
- debug("ERST Max: %lx -> %lx entries\n", XHCI_INST (controller)->capreg->ERST_Max, 1<<(XHCI_INST (controller)->capreg->ERST_Max));
+ usb_debug("ERST Max: %lx -> %lx entries\n", XHCI_INST (controller)->capreg->ERST_Max, 1<<(XHCI_INST (controller)->capreg->ERST_Max));
// enable all available slots
XHCI_INST (controller)->opreg->config = XHCI_INST (controller)->capreg->MaxSlots & CONFIG_MASK_MaxSlotsEn;
@@ -161,7 +161,7 @@ xhci_init (pcidev_t addr)
cmd->cmd_No_Op.TRB_Type = TRB_CMD_NOOP;
// ring the HC doorbell
- debug("Posting command at %lx\n", virt_to_phys(cmd));
+ usb_debug("Posting command at %lx\n", virt_to_phys(cmd));
cmd->cmd_No_Op.C = XHCI_INST (controller)->cmd_ccs; // enable command
XHCI_INST (controller)->dbreg[0] = 0; // and tell controller to consume commands
@@ -169,27 +169,27 @@ xhci_init (pcidev_t addr)
trb_t *ev = &XHCI_INST (controller)->ev_ring[0];
trb_t *ev1 = &XHCI_INST (controller)->ev_ring[1];
while (ev->event_cmd_cmpl.C != XHCI_INST (controller)->ev_ccs) {
- debug("CRCR: %lx, USBSTS: %lx\n", XHCI_INST (controller)->opreg->crcr_lo, XHCI_INST (controller)->opreg->usbsts);
- debug("ev0.C %x, ev1.C %x\n", ev->event_cmd_cmpl.C, ev1->event_cmd_cmpl.C);
+ usb_debug("CRCR: %lx, USBSTS: %lx\n", XHCI_INST (controller)->opreg->crcr_lo, XHCI_INST (controller)->opreg->usbsts);
+ usb_debug("ev0.C %x, ev1.C %x\n", ev->event_cmd_cmpl.C, ev1->event_cmd_cmpl.C);
mdelay(100);
}
- debug("command ring is %srunning\n", (XHCI_INST (controller)->opreg->crcr_lo & CRCR_CRR)?"":"not ");
+ usb_debug("command ring is %srunning\n", (XHCI_INST (controller)->opreg->crcr_lo & CRCR_CRR)?"":"not ");
switch (ev->event_cmd_cmpl.TRB_Type) {
case TRB_EV_CMD_CMPL:
- debug("Completed command TRB at %lx. Code: %d\n",
+ usb_debug("Completed command TRB at %lx. Code: %d\n",
ev->event_cmd_cmpl.Cmd_TRB_Pointer_lo, ev->event_cmd_cmpl.Completion_Code);
break;
case TRB_EV_PORTSC:
- debug("Port Status Change Event. Completion Code: %d\n Port: %d. Ignoring.\n",
+ usb_debug("Port Status Change Event. Completion Code: %d\n Port: %d. Ignoring.\n",
ev->event_cmd_cmpl.Completion_Code, ev->event_portsc.Port);
// we ignore the event as we look for the PORTSC registers instead, at a time when it suits _us_
break;
default:
- debug("Unknown event: %d, Completion Code: %d\n", ev->event_cmd_cmpl.TRB_Type, ev->event_cmd_cmpl.Completion_Code);
+ usb_debug("Unknown event: %d, Completion Code: %d\n", ev->event_cmd_cmpl.TRB_Type, ev->event_cmd_cmpl.Completion_Code);
break;
}
- debug("CRCR: %lx, USBSTS: %lx\n", XHCI_INST (controller)->opreg->crcr_lo, XHCI_INST (controller)->opreg->usbsts);
- debug("ev0.C %x, ev1.C %x, ev1.CC %d\n", ev->event_cmd_cmpl.C, ev1->event_cmd_cmpl.C, ev1->event_cmd_cmpl.Completion_Code);
+ usb_debug("CRCR: %lx, USBSTS: %lx\n", XHCI_INST (controller)->opreg->crcr_lo, XHCI_INST (controller)->opreg->usbsts);
+ usb_debug("ev0.C %x, ev1.C %x, ev1.CC %d\n", ev->event_cmd_cmpl.C, ev1->event_cmd_cmpl.C, ev1->event_cmd_cmpl.Completion_Code);
controller->devices[0]->controller = controller;
controller->devices[0]->init = xhci_rh_init;
diff --git a/payloads/libpayload/drivers/usb/xhci_rh.c b/payloads/libpayload/drivers/usb/xhci_rh.c
index 1547ef62e2..58eb6c328d 100644
--- a/payloads/libpayload/drivers/usb/xhci_rh.c
+++ b/payloads/libpayload/drivers/usb/xhci_rh.c
@@ -64,7 +64,7 @@ xhci_rh_scanport (usbdev_t *dev, int port)
val |= PORTSC_CSC;
XHCI_INST (dev->controller)->opreg->prs[port].portsc = val;
- debug("device attach status on port %x: %x\n", port, XHCI_INST (dev->controller)->opreg->prs[port].portsc & PORTSC_CCS);
+ usb_debug("device attach status on port %x: %x\n", port, XHCI_INST (dev->controller)->opreg->prs[port].portsc & PORTSC_CCS);
}
static int
@@ -77,7 +77,7 @@ xhci_rh_report_port_changes (usbdev_t *dev)
for (i = 0; i < RH_INST (dev)->numports; i++) {
if (XHCI_INST (dev->controller)->opreg->prs[i].portsc & PORTSC_CSC) {
- debug("found connect status change on port %d\n", i);
+ usb_debug("found connect status change on port %d\n", i);
return i;
}
}
@@ -116,7 +116,7 @@ xhci_rh_init (usbdev_t *dev)
RH_INST (dev)->numports = XHCI_INST (dev->controller)->capreg->MaxPorts;
RH_INST (dev)->port = malloc(sizeof(int) * RH_INST (dev)->numports);
- debug("%d ports registered\n", RH_INST (dev)->numports);
+ usb_debug("%d ports registered\n", RH_INST (dev)->numports);
for (i = 0; i < RH_INST (dev)->numports; i++) {
xhci_rh_enable_port (dev, i);
@@ -129,5 +129,5 @@ xhci_rh_init (usbdev_t *dev)
dev->hub = -1;
dev->port = -1;
- debug("rh init done\n");
+ usb_debug("rh init done\n");
}
diff --git a/payloads/libpayload/include/usb/usb.h b/payloads/libpayload/include/usb/usb.h
index 27af9bc3a0..17eca01bd1 100644
--- a/payloads/libpayload/include/usb/usb.h
+++ b/payloads/libpayload/include/usb/usb.h
@@ -253,10 +253,14 @@ int usb_interface_check(u16 vendor, u16 device);
#define USB_QUIRK_TEST (1 << 31)
#define USB_QUIRK_NONE 0
+static inline void usb_debug(const char *fmt, ...)
+{
#ifdef USB_DEBUG
-# define debug(fmt, ...) printf(fmt, ##__VA_ARGS__)
-#else
-# define debug(fmt, ...) while (0) { printf(fmt, ##__VA_ARGS__); }
+ va_list ap;
+ va_start(ap, fmt);
+ vprintf(fmt, ap);
+ va_end(ap);
#endif
+}
#endif