thunderbolt: make code -Wunused clean

This change modifies code paths and uses `__diagused` to address `-Wunused`
issues that occur when `THUNDERBOLT_DEBUG` == `0`.

MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D55575
This commit is contained in:
Enji Cooper
2026-02-26 00:06:49 -08:00
parent 96eaa6857f
commit 1836330791
6 changed files with 24 additions and 17 deletions
+11 -7
View File
@@ -788,8 +788,11 @@ nhi_tx_schedule(struct nhi_ring_pair *r, struct nhi_cmd_frame *cmd)
int
nhi_tx_synchronous(struct nhi_ring_pair *r, struct nhi_cmd_frame *cmd)
{
struct nhi_softc *sc __diagused;
int error, count;
sc = r->sc;
if ((error = nhi_tx_schedule(r, cmd)) != 0)
return (error);
@@ -812,16 +815,16 @@ nhi_tx_synchronous(struct nhi_ring_pair *r, struct nhi_cmd_frame *cmd)
if ((cmd->flags & CMD_REQ_COMPLETE) == 0)
error = ETIMEDOUT;
tb_debug(r->sc, DBG_TXQ|DBG_FULL, "tx_synchronous done waiting, "
tb_debug(sc, DBG_TXQ|DBG_FULL, "tx_synchronous done waiting, "
"err= %d, TX_COMPLETE= %d\n", error,
!!(cmd->flags & CMD_REQ_COMPLETE));
if (error == ERESTART) {
tb_printf(r->sc, "TX command interrupted\n");
tb_printf(sc, "TX command interrupted\n");
} else if ((error == EWOULDBLOCK) || (error == ETIMEDOUT)) {
tb_printf(r->sc, "TX command timed out\n");
tb_printf(sc, "TX command timed out\n");
} else if (error != 0) {
tb_printf(r->sc, "TX command failed error= %d\n", error);
tb_printf(sc, "TX command failed error= %d\n", error);
}
return (error);
@@ -831,7 +834,7 @@ static int
nhi_tx_complete(struct nhi_ring_pair *r, struct nhi_tx_buffer_desc *desc,
struct nhi_cmd_frame *cmd)
{
struct nhi_softc *sc;
struct nhi_softc *sc __diagused;
struct nhi_pdf_dispatch *txpdf;
u_int sof;
@@ -865,9 +868,10 @@ static int
nhi_rx_complete(struct nhi_ring_pair *r, struct nhi_rx_post_desc *desc,
struct nhi_cmd_frame *cmd)
{
struct nhi_softc *sc;
struct nhi_softc *sc __diagused;
struct nhi_pdf_dispatch *rxpdf;
u_int eof, len;
u_int eof;
u_int len __diagused;
sc = r->sc;
eof = desc->eof_len >> RX_BUFFER_DESC_EOF_SHIFT;
+7 -4
View File
@@ -277,7 +277,8 @@ _tb_router_attach(struct router_softc *sc)
{
struct tb_cfg_router *cfg;
uint32_t *buf;
int error, up;
int error;
int up __diagused;
buf = malloc(9 * 4, M_THUNDERBOLT, M_NOWAIT|M_ZERO);
if (buf == NULL)
@@ -297,8 +298,9 @@ _tb_router_attach(struct router_softc *sc)
sc->uuid[1] = cfg->uuid_hi;
sc->uuid[2] = 0xffffffff;
sc->uuid[3] = 0xffffffff;
tb_debug(sc, DBG_ROUTER, "Router upstream_port= %d, max_port= %d, "
"depth= %d\n", up, sc->max_adap, sc->depth);
tb_debug(sc, DBG_ROUTER,
"Router upstream_port= %d, max_port= %d, depth= %d\n",
up, sc->max_adap, sc->depth);
free(buf, M_THUNDERBOLT);
/* Downstream adapters are indexed in the array allocated here. */
@@ -718,7 +720,8 @@ router_notify_intr(void *context, union nhi_ring_desc *ring, struct nhi_cmd_fram
struct router_softc *sc;
struct router_command *cmd;
struct tb_cfg_notify event;
u_int ev, adap;
u_int adap __diagused;
u_int ev;
KASSERT(context != NULL, ("context cannot be NULL\n"));
+1 -1
View File
@@ -120,7 +120,7 @@ tb_acpi_pcib_attach(device_t dev)
ACPI_OBJECT_LIST list;
ACPI_OBJECT arg;
ACPI_BUFFER buf;
ACPI_STATUS s;
ACPI_STATUS s __diagused;
tb_debug(sc, DBG_BRIDGE, "Executing OSUP\n");
+3 -3
View File
@@ -206,7 +206,7 @@ int
tb_debug_sysctl(SYSCTL_HANDLER_ARGS)
{
struct sbuf *sbuf;
#if defined (THUNDERBOLT_DEBUG) && (THUNDERBOLT_DEBUG > 0)
#ifdef THUNDERBOLT_DEBUG
struct tb_debug_string *string;
char *buffer;
size_t sz;
@@ -221,7 +221,7 @@ tb_debug_sysctl(SYSCTL_HANDLER_ARGS)
sbuf = sbuf_new_for_sysctl(NULL, NULL, 128, req);
#if defined (THUNDERBOLT_DEBUG) && (THUNDERBOLT_DEBUG > 0)
#ifdef THUNDERBOLT_DEBUG
debug = (u_int *)arg1;
sbuf_printf(sbuf, "%#x", *debug);
@@ -317,7 +317,7 @@ tb_parse_debug(u_int *debug, char *list)
void
tbdbg_dprintf(device_t dev, u_int debug, u_int val, const char *fmt, ...)
{
#if defined(THUNDERBOLT_DEBUG) && (THUNDERBOLT_DEBUG > 0)
#ifdef THUNDERBOLT_DEBUG
va_list ap;
u_int lvl, dbg;
+1 -1
View File
@@ -81,7 +81,7 @@ enum {
*/
void tbdbg_dprintf(device_t dev, u_int debug, u_int val, const char *fmt, ...) __printflike(4, 5);
#if defined(THUNDERBOLT_DEBUG) && (THUNDERBOLT_DEBUG > 0)
#ifdef THUNDERBOLT_DEBUG
#define tb_debug(sc, level, fmt...) \
tbdbg_dprintf((sc)->dev, (sc)->debug, level, ##fmt)
#else
+1 -1
View File
@@ -304,7 +304,7 @@ static int
tb_pcib_detach(device_t dev)
{
struct tb_pcib_softc *sc;
int error;
int error __diagused;
sc = device_get_softc(dev);