From 8079a6a558526730d994aa56bf23139fbad2141c Mon Sep 17 00:00:00 2001 From: Caveh Jalali Date: Tue, 1 Sep 2020 20:37:49 -0700 Subject: libpayload/usb: Fix printf format string mismatches in debug messages This fixes format string mismatch errors in the USB subsystem found by the compiler's format string checker. BUG=b:167517417 TEST=enabled all USB controllers on volteer and fixed resulting compiler errors when USB_DEBUG is enabled. Change-Id: I4dc70baefb3cd82fcc915cc2e7f68719cf6870cc Signed-off-by: Caveh Jalali Reviewed-on: https://review.coreboot.org/c/coreboot/+/45024 Tested-by: build bot (Jenkins) Reviewed-by: Tim Wawrzynczak --- payloads/libpayload/drivers/usb/ehci.c | 17 ++++++++++------- payloads/libpayload/drivers/usb/ohci.c | 19 ++++++++++--------- payloads/libpayload/drivers/usb/uhci.c | 9 +++++---- payloads/libpayload/drivers/usb/usb.c | 3 ++- payloads/libpayload/drivers/usb/xhci.c | 12 ++++++------ 5 files changed, 33 insertions(+), 27 deletions(-) (limited to 'payloads') diff --git a/payloads/libpayload/drivers/usb/ehci.c b/payloads/libpayload/drivers/usb/ehci.c index 97caf202d9..58fc64eead 100644 --- a/payloads/libpayload/drivers/usb/ehci.c +++ b/payloads/libpayload/drivers/usb/ehci.c @@ -28,6 +28,7 @@ //#define USB_DEBUG +#include #include #include #include @@ -46,15 +47,15 @@ static void dump_td(u32 addr) usb_debug("|..[OUT]............................................|\n"); else usb_debug("|..[]...............................................|\n"); - usb_debug("|:|============ EHCI TD at [0x%08lx] ==========|:|\n", addr); - usb_debug("|:| ERRORS = [%ld] | TOKEN = [0x%08lx] | |:|\n", + usb_debug("|:|============ EHCI TD at [0x%08"PRIx32"] ==========|:|\n", addr); + usb_debug("|:| ERRORS = [%"PRId32"] | TOKEN = [0x%08"PRIx32"] | |:|\n", 3 - ((td->token & QTD_CERR_MASK) >> QTD_CERR_SHIFT), td->token); usb_debug("|:+-----------------------------------------------+:|\n"); - usb_debug("|:| Next qTD [0x%08lx] |:|\n", td->next_qtd); + usb_debug("|:| Next qTD [0x%08"PRIx32"] |:|\n", td->next_qtd); usb_debug("|:+-----------------------------------------------+:|\n"); - usb_debug("|:| Alt. Next qTD [0x%08lx] |:|\n", td->alt_next_qtd); + usb_debug("|:| Alt. Next qTD [0x%08"PRIx32"] |:|\n", td->alt_next_qtd); usb_debug("|:+-----------------------------------------------+:|\n"); - usb_debug("|:| | Bytes to Transfer |[%05ld] |:|\n", (td->token & QTD_TOTAL_LEN_MASK) >> 16); + usb_debug("|:| | Bytes to Transfer |[%05"PRId32"] |:|\n", (td->token & QTD_TOTAL_LEN_MASK) >> 16); usb_debug("|:| | PID CODE: | [%ld] |:|\n", (td->token & (3UL << 8)) >> 8); usb_debug("|:| | Interrupt On Complete (IOC) | [%ld] |:|\n", (td->token & (1UL << 15)) >> 15); usb_debug("|:| | Status Active | [%ld] |:|\n", (td->token & (1UL << 7)) >> 7); @@ -277,9 +278,11 @@ static int wait_for_tds(qtd_t *head) if (cur->next_qtd & 1) { break; } - if (0) dump_td(virt_to_phys(cur)); + if (0) + dump_td(virt_to_phys(cur)); /* helps debugging the TD chain */ - if (0) usb_debug("\nmoving from %x to %x\n", cur, phys_to_virt(cur->next_qtd)); + if (0) + usb_debug("\nmoving from %p to %p\n", cur, phys_to_virt(cur->next_qtd)); cur = phys_to_virt(cur->next_qtd); } return result; diff --git a/payloads/libpayload/drivers/usb/ohci.c b/payloads/libpayload/drivers/usb/ohci.c index ec14144711..f35d1ff0e8 100644 --- a/payloads/libpayload/drivers/usb/ohci.c +++ b/payloads/libpayload/drivers/usb/ohci.c @@ -29,6 +29,7 @@ //#define USB_DEBUG #include +#include #include #include "ohci_private.h" #include "ohci.h" @@ -59,7 +60,7 @@ dump_td (td_t *cur) else usb_debug("|..[]...............................................|\n"); usb_debug("|:|============ OHCI TD at [0x%08lx] ==========|:|\n", virt_to_phys(cur)); - usb_debug("|:| ERRORS = [%ld] | CONFIG = [0x%08lx] | |:|\n", + usb_debug("|:| ERRORS = [%ld] | CONFIG = [0x%08"PRIx32"] | |:|\n", 3 - ((cur->config & (3UL << 26)) >> 26), cur->config); usb_debug("|:+-----------------------------------------------+:|\n"); usb_debug("|:| C | Condition Code | [%02ld] |:|\n", (cur->config & (0xFUL << 28)) >> 28); @@ -69,11 +70,11 @@ dump_td (td_t *cur) usb_debug("|:| I | Data Toggle | [%ld] |:|\n", (cur->config & (3UL << 24)) >> 24); usb_debug("|:| G | Error Count | [%ld] |:|\n", (cur->config & (3UL << 26)) >> 26); usb_debug("|:+-----------------------------------------------+:|\n"); - usb_debug("|:| Current Buffer Pointer [0x%08lx] |:|\n", cur->current_buffer_pointer); + usb_debug("|:| Current Buffer Pointer [0x%08"PRIx32"] |:|\n", cur->current_buffer_pointer); usb_debug("|:+-----------------------------------------------+:|\n"); - usb_debug("|:| Next TD [0x%08lx] |:|\n", cur->next_td); + usb_debug("|:| Next TD [0x%08"PRIx32"] |:|\n", cur->next_td); usb_debug("|:+-----------------------------------------------+:|\n"); - usb_debug("|:| Current Buffer End [0x%08lx] |:|\n", cur->buffer_end); + usb_debug("|:| Current Buffer End [0x%08"PRIx32"] |:|\n", cur->buffer_end); usb_debug("|:|-----------------------------------------------|:|\n"); usb_debug("|...................................................|\n"); usb_debug("+---------------------------------------------------+\n"); @@ -88,9 +89,9 @@ dump_ed (ed_t *cur) usb_debug("+---------------------------------------------------+\n"); usb_debug("| Next Endpoint Descriptor [0x%08lx] |\n", cur->next_ed & ~0xFUL); usb_debug("+---------------------------------------------------+\n"); - usb_debug("| | @ 0x%08lx : |\n", cur->config); + usb_debug("| | @ 0x%08"PRIx32" : |\n", cur->config); usb_debug("| C | Maximum Packet Length | [%04ld] |\n", ((cur->config & (0x3fffUL << 16)) >> 16)); - usb_debug("| O | Function Address | [%04ld] |\n", cur->config & 0x7F); + usb_debug("| O | Function Address | [%04"PRIx32"] |\n", cur->config & 0x7F); usb_debug("| N | Endpoint Number | [%02ld] |\n", (cur->config & (0xFUL << 7)) >> 7); usb_debug("| F | Endpoint Direction | [%ld] |\n", ((cur->config & (3UL << 11)) >> 11)); usb_debug("| I | Endpoint Speed | [%ld] |\n", ((cur->config & (1UL << 13)) >> 13)); @@ -468,7 +469,7 @@ ohci_control (usbdev_t *dev, direction_t dir, int drlen, void *setup, int dalen, head->tail_pointer = virt_to_phys(final_td); head->head_pointer = virt_to_phys(first_td); - usb_debug("ohci_control(): doing transfer with %x. first_td at %x\n", + usb_debug("%s(): doing transfer with %x. first_td at %"PRIxPTR"\n", __func__, head->config & ED_FUNC_MASK, virt_to_phys(first_td)); #ifdef USB_DEBUG dump_ed(head); @@ -506,7 +507,7 @@ ohci_bulk (endpoint_t *ep, int dalen, u8 *src, int finalize) td_t *cur, *next; int remaining = dalen; u8 *data = src; - usb_debug("bulk: %x bytes from %x, finalize: %x, maxpacketsize: %x\n", dalen, src, finalize, ep->maxpacketsize); + usb_debug("bulk: %x bytes from %p, finalize: %x, maxpacketsize: %x\n", dalen, src, finalize, ep->maxpacketsize); if (!dma_coherent(src)) { data = OHCI_INST(ep->dev->controller)->dma_buffer; @@ -596,7 +597,7 @@ ohci_bulk (endpoint_t *ep, int dalen, u8 *src, int finalize) head->tail_pointer = virt_to_phys(cur); head->head_pointer = virt_to_phys(first_td) | (ep->toggle?ED_TOGGLE:0); - usb_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 %"PRIxPTR", last %"PRIxPTR"\n", head->config & ED_FUNC_MASK, (head->config & ED_EP_MASK) >> ED_EP_SHIFT, virt_to_phys(first_td), virt_to_phys(cur)); diff --git a/payloads/libpayload/drivers/usb/uhci.c b/payloads/libpayload/drivers/usb/uhci.c index c6a178703c..b87ec26965 100644 --- a/payloads/libpayload/drivers/usb/uhci.c +++ b/payloads/libpayload/drivers/usb/uhci.c @@ -29,6 +29,7 @@ //#define USB_DEBUG #include +#include #include #include "uhci.h" #include "uhci_private.h" @@ -79,14 +80,14 @@ static void td_dump(td_t *td) (td->ptr & (1UL << 2)) >> 2, (td->ptr & (1UL << 1)) >> 1, td->ptr & 1UL); usb_debug("|:+-----------------------------------------------+:|\n"); usb_debug("|:| T | Maximum Length | [%04lx] |:|\n", (td->token & (0x7FFUL << 21)) >> 21); - usb_debug("|:| O | PID CODE | [%04lx] |:|\n", td->token & 0xFF); - usb_debug("|:| K | Endpoint | [%04lx] |:|\n", (td->token & TD_EP_MASK) >> TD_EP_SHIFT); + usb_debug("|:| O | PID CODE | [%04"PRIx32"] |:|\n", td->token & 0xFF); + usb_debug("|:| K | Endpoint | [%04"PRIx32"] |:|\n", (td->token & TD_EP_MASK) >> TD_EP_SHIFT); usb_debug("|:| E | Device Address | [%04lx] |:|\n", (td->token & (0x7FUL << 8)) >> 8); usb_debug("|:| N | Data Toggle | [%lx] |:|\n", (td->token & (1UL << 19)) >> 19); usb_debug("|:+-----------------------------------------------+:|\n"); usb_debug("|:| C | Short Packet Detector | [%lx] |:|\n", (td->ctrlsts & (1UL << 29)) >> 29); usb_debug("|:| O | Error Counter | [%lx] |:|\n", - (td->ctrlsts & (3UL << TD_COUNTER_SHIFT)) >> TD_COUNTER_SHIFT); + (td->ctrlsts & (3UL << TD_COUNTER_SHIFT)) >> TD_COUNTER_SHIFT); usb_debug("|:| N | Low Speed Device | [%lx] |:|\n", (td->ctrlsts & (1UL << 26)) >> 26); usb_debug("|:| T | Isochronous Select | [%lx] |:|\n", (td->ctrlsts & (1UL << 25)) >> 25); usb_debug("|:| R | Interrupt on Complete (IOC) | [%lx] |:|\n", (td->ctrlsts & (1UL << 24)) >> 24); @@ -101,7 +102,7 @@ static void td_dump(td_t *td) usb_debug("|:| S ----------------------------------------|:|\n"); usb_debug("|:| | Actual Length | [%04lx] |:|\n", td->ctrlsts & 0x7FFUL); usb_debug("|:+-----------------------------------------------+:|\n"); - usb_debug("|:| Buffer pointer [0x%08lx] |:|\n", td->bufptr); + usb_debug("|:| Buffer pointer [0x%08"PRIx32"] |:|\n", td->bufptr); usb_debug("|:|-----------------------------------------------|:|\n"); usb_debug("|...................................................|\n"); usb_debug("+---------------------------------------------------+\n"); diff --git a/payloads/libpayload/drivers/usb/usb.c b/payloads/libpayload/drivers/usb/usb.c index ec49a5481e..ed33147c51 100644 --- a/payloads/libpayload/drivers/usb/usb.c +++ b/payloads/libpayload/drivers/usb/usb.c @@ -28,6 +28,7 @@ //#define USB_DEBUG +#include #include #include @@ -229,7 +230,7 @@ get_free_address (hci_t *controller) int i = controller->latest_address + 1; for (; i != controller->latest_address; i++) { if (i >= ARRAY_SIZE(controller->devices) || i < 1) { - usb_debug("WARNING: Device addresses for controller %#x" + usb_debug("WARNING: Device addresses for controller %#" PRIxPTR " wrapped around!\n", controller->reg_base); i = 0; continue; diff --git a/payloads/libpayload/drivers/usb/xhci.c b/payloads/libpayload/drivers/usb/xhci.c index 749ff0a066..c40e641c4c 100644 --- a/payloads/libpayload/drivers/usb/xhci.c +++ b/payloads/libpayload/drivers/usb/xhci.c @@ -194,7 +194,7 @@ xhci_init (unsigned long physical_bar) xhci->hcrreg = phys_to_virt(physical_bar) + xhci->capreg->rtsoff; xhci->dbreg = phys_to_virt(physical_bar) + xhci->capreg->dboff; - xhci_debug("regbase: 0x%"PRIx32"\n", physical_bar); + xhci_debug("regbase: 0x%"PRIxPTR"\n", physical_bar); xhci_debug("caplen: 0x%"PRIx32"\n", CAP_GET(CAPLEN, xhci->capreg)); xhci_debug("rtsoff: 0x%"PRIx32"\n", xhci->capreg->rtsoff); xhci_debug("dboff: 0x%"PRIx32"\n", xhci->capreg->dboff); @@ -208,8 +208,8 @@ xhci_init (unsigned long physical_bar) } xhci_debug("context size: %dB\n", CTXSIZE(xhci)); - xhci_debug("maxslots: 0x%02lx\n", CAP_GET(MAXSLOTS, xhci->capreg)); - xhci_debug("maxports: 0x%02lx\n", CAP_GET(MAXPORTS, xhci->capreg)); + xhci_debug("maxslots: 0x%02"PRIx32"\n", CAP_GET(MAXSLOTS, xhci->capreg)); + xhci_debug("maxports: 0x%02"PRIx32"\n", CAP_GET(MAXPORTS, xhci->capreg)); const unsigned pagesize = xhci->opreg->pagesize << 12; xhci_debug("pagesize: 0x%04x\n", pagesize); @@ -374,7 +374,7 @@ xhci_reinit (hci_t *controller) /* Initialize command ring */ xhci_init_cycle_ring(&xhci->cr, COMMAND_RING_SIZE); - xhci_debug("command ring @%p (0x%08x)\n", + xhci_debug("command ring @%p (0x%08"PRIxPTR")\n", xhci->cr.ring, virt_to_phys(xhci->cr.ring)); xhci->opreg->crcr_lo = virt_to_phys(xhci->cr.ring) | CRCR_RCS; xhci->opreg->crcr_hi = 0; @@ -384,9 +384,9 @@ xhci_reinit (hci_t *controller) /* Initialize event ring */ xhci_reset_event_ring(&xhci->er); - xhci_debug("event ring @%p (0x%08x)\n", + xhci_debug("event ring @%p (0x%08"PRIxPTR")\n", xhci->er.ring, virt_to_phys(xhci->er.ring)); - xhci_debug("ERST Max: 0x%lx -> 0x%lx entries\n", + xhci_debug("ERST Max: 0x%"PRIx32" -> 0x%x entries\n", CAP_GET(ERST_MAX, xhci->capreg), 1 << CAP_GET(ERST_MAX, xhci->capreg)); memset((void*)xhci->ev_ring_table, 0x00, sizeof(erst_entry_t)); -- cgit v1.2.3