git: 40accc7235c2 - main - aq(4): adopt native FreeBSD errno convention
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 20 Jun 2026 19:10:36 UTC
The branch main has been updated by adrian:
URL: https://cgit.FreeBSD.org/src/commit/?id=40accc7235c2f0d2072f051099d183e7f21c2731
commit 40accc7235c2f0d2072f051099d183e7f21c2731
Author: Nick Price <nick@spun.io>
AuthorDate: 2026-06-20 19:02:42 +0000
Commit: Adrian Chadd <adrian@FreeBSD.org>
CommitDate: 2026-06-20 19:10:15 +0000
aq(4): adopt native FreeBSD errno convention
Convert the driver's internal error-handling chain from the Linux
negative-errno convention to FreeBSD positive errno everywhere.
- All `return (-EXXX)` become `return (EXXX)`, `int err = -EXXX` loses
the sign, and `if (err < 0)` checks become `if (err != 0)` across
aq_fw.c, aq_fw1x.c, aq_fw2x.c and aq_hw.c.
- mac_soft_reset_flb_ returns ETIMEDOUT/0 instead of a bool so it
matches its RBL sibling.
- The ETIME and EOK aliases in aq_common.h are removed; all sites use
ETIMEDOUT and 0 directly, and the `rc = -rc` sign flips in
aq_if_attach_pre are dropped.
Turn AQ_HW_WAIT_FOR into a statement expression evaluating to 0 on
success or ETIMEDOUT on timeout, assigned explicitly at all seven call
sites, instead of silently assigning ETIMEDOUT to a variable named err
in the caller scope. A statement expression rather than an inline
function because every call must re-evaluate its condition each
iteration -- one even assigns hw->mbox_addr as a side effect.
Fix two correctness bugs surfaced by the conversion:
- fw1x_get_stats gated its stats copy with `if (err >= 0)`, correct
under negative errno but accepting every positive errno after the
flip. Change to `if (err == 0)`.
- fw2x_reset returned 0 regardless of capability-download failure,
silently leaving fw_caps = 0. Return the real err.
Harden aq_if_attach_pre: bit_alloc(4096, M_AQ, M_NOWAIT) was unchecked,
so under OOM a later `ifconfig vlanN create` would NULL-deref the
bitstring; check for NULL and fail with ENOMEM. The fail label's
hardcoded `return (ENXIO)` becomes `return (rc)` so each error path
reports its real errno.
Remove the dead error checks in aq_hw_offload_set: the
`if (err != 0) goto err_exit` blocks after the void tpo_/rpo_/tdm_
register-write helpers were unreachable (err is never set), and the real
error capture is the aq_hw_err_from_flags call at the function tail.
Drop the now-orphaned err_exit label.
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D57435
---
sys/dev/aq/aq_common.h | 17 ++++----------
sys/dev/aq/aq_fw.c | 32 ++++++++++++-------------
sys/dev/aq/aq_fw1x.c | 24 +++++++++----------
sys/dev/aq/aq_fw2x.c | 34 +++++++++++++--------------
sys/dev/aq/aq_hw.c | 64 ++++++++++++++++++++++----------------------------
sys/dev/aq/aq_main.c | 21 ++++++++++-------
6 files changed, 91 insertions(+), 101 deletions(-)
diff --git a/sys/dev/aq/aq_common.h b/sys/dev/aq/aq_common.h
index f31567480ec0..6529f249ff62 100644
--- a/sys/dev/aq/aq_common.h
+++ b/sys/dev/aq/aq_common.h
@@ -38,9 +38,6 @@
#include <sys/types.h>
-#define ETIME ETIMEDOUT
-#define EOK 0
-
#define BIT(nr) (1UL << (nr))
#define usec_delay(x) DELAY(x)
@@ -50,16 +47,12 @@
#define msec_delay_irq(x) DELAY(x*1000)
#endif
-#define AQ_HW_WAIT_FOR(_B_, _US_, _N_) \
-do { \
- unsigned int i; \
- for (i = _N_; (!(_B_)) && i; --i) { \
+#define AQ_HW_WAIT_FOR(_B_, _US_, _N_) ({ \
+ unsigned int _i; \
+ for (_i = (_N_); !(_B_) && _i; --_i) \
usec_delay(_US_); \
- } \
- if (!i) { \
- err = -1; \
- } \
-} while (0)
+ (_i == 0) ? ETIMEDOUT : 0; \
+})
#define LOWORD(a) ((uint16_t)(a))
diff --git a/sys/dev/aq/aq_fw.c b/sys/dev/aq/aq_fw.c
index 3ab5909882e1..487137e9c61e 100644
--- a/sys/dev/aq/aq_fw.c
+++ b/sys/dev/aq/aq_fw.c
@@ -112,7 +112,7 @@ aq_fw_reset(struct aq_hw* hw)
if (k == 1000) {
aq_log_error("Neither RBL nor FLB started");
- return (-EBUSY);
+ return (EBUSY);
}
hw->rbl_enabled = bootExitCode != 0;
@@ -133,7 +133,7 @@ aq_fw_reset(struct aq_hw* hw)
aq_fw_bootloader_mode mode = boot_mode_unknown;
int err = mac_soft_reset_(hw, &mode);
- if (err < 0) {
+ if (err != 0) {
aq_log_error("MAC reset failed: %d", err);
return (err);
}
@@ -151,12 +151,12 @@ aq_fw_reset(struct aq_hw* hw)
case boot_mode_unknown:
aq_log_error("F/W bootload error: unknown bootloader type");
- return (-ENOTSUP);
+ return (ENOTSUP);
case boot_mode_rbl_host_bootload:
#if AQ_CFG_HOST_BOOT_DISABLE
aq_log_error("RBL> Host Bootload mode: this driver does not support Host Boot");
- return (-ENOTSUP);
+ return (ENOTSUP);
#else
trace(dbg_init, "RBL> Host Bootload mode");
break;
@@ -168,7 +168,7 @@ aq_fw_reset(struct aq_hw* hw)
*/
aq_log_error("RBL> F/W Host Bootload not implemented");
- return (-ENOTSUP);
+ return (ENOTSUP);
}
int
@@ -184,16 +184,16 @@ aq_fw_ops_init(struct aq_hw* hw)
if (hw->fw_version.major_version == 1) {
trace(dbg_init, "using F/W ops v1.x");
hw->fw_ops = &aq_fw1x_ops;
- return (EOK);
+ return (0);
} else if (hw->fw_version.major_version >= 2) {
trace(dbg_init, "using F/W ops v2.x");
hw->fw_ops = &aq_fw2x_ops;
- return (EOK);
+ return (0);
}
aq_log_error("aq_fw_ops_init(): invalid F/W version %#x",
hw->fw_version.raw);
- return (-ENOTSUP);
+ return (ENOTSUP);
}
@@ -260,7 +260,7 @@ mac_soft_reset_flb_(struct aq_hw* hw)
if (flb_status == 0) {
trace_error(dbg_init,
"FLB> MAC kickstart failed: timed out");
- return (false);
+ return (ETIMEDOUT);
}
trace(dbg_init, "FLB> MAC kickstart done, %d ms", k);
@@ -290,11 +290,11 @@ mac_soft_reset_flb_(struct aq_hw* hw)
if (!restart_completed) {
trace_error(dbg_init, "FLB> Global Soft Reset failed");
- return (false);
+ return (ETIMEDOUT);
}
trace(dbg_init, "FLB> F/W restart: %d ms", k * 10);
- return (true);
+ return (0);
}
int
@@ -331,7 +331,7 @@ mac_soft_reset_rbl_(struct aq_hw* hw, aq_fw_bootloader_mode* mode)
if (rbl_status == 0 || rbl_status == 0xDEAD) {
trace_error(dbg_init, "RBL> RBL restart failed: timeout");
- return (-EBUSY);
+ return (EBUSY);
}
if (rbl_status == RBL_STATUS_SUCCESS) {
@@ -344,10 +344,10 @@ mac_soft_reset_rbl_(struct aq_hw* hw, aq_fw_bootloader_mode* mode)
trace(dbg_init, "RBL> reset complete! [Host Bootload]");
} else {
trace_error(dbg_init, "unknown RBL status 0x%x", rbl_status);
- return (-EBUSY);
+ return (EBUSY);
}
- return (EOK);
+ return (0);
}
int
@@ -355,12 +355,12 @@ wait_init_mac_firmware_(struct aq_hw* hw)
{
for (int i = 0; i < MAC_FW_START_TIMEOUT_MS; ++i) {
if ((hw->fw_version.raw = AQ_READ_REG(hw, 0x18)) != 0)
- return (EOK);
+ return (0);
msec_delay(1);
}
trace_error(dbg_init,
"timeout waiting for reg 0x18. MAC f/w NOT READY");
- return (-EBUSY);
+ return (EBUSY);
}
diff --git a/sys/dev/aq/aq_fw1x.c b/sys/dev/aq/aq_fw1x.c
index 5a409eef15f4..f5458b174c3f 100644
--- a/sys/dev/aq/aq_fw1x.c
+++ b/sys/dev/aq/aq_fw1x.c
@@ -186,7 +186,7 @@ fw1x_reset(struct aq_hw* hal)
* Compare transaction ID to initial value.
* If it's different means f/w is alive. We're done.
*/
- return (EOK);
+ return (0);
}
/*
@@ -197,7 +197,7 @@ fw1x_reset(struct aq_hw* hal)
}
trace_error(dbg_init, "F/W 1.x reset finalize timeout");
- return (-EBUSY);
+ return (EBUSY);
}
int
@@ -213,7 +213,7 @@ fw1x_set_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state_e mode,
AQ_WRITE_REG(hw, FW1X_MPI_CONTROL_ADR, state.val);
- return (EOK);
+ return (0);
}
int
@@ -250,15 +250,15 @@ fw1x_get_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state_e* mode,
*fc = aq_fw_fc_none;
- AQ_DBG_EXIT(EOK);
- return (EOK);
+ AQ_DBG_EXIT(0);
+ return (0);
}
int
fw1x_get_mac_addr(struct aq_hw* hw, uint8_t* mac)
{
- int err = -EFAULT;
+ int err = EFAULT;
uint32_t mac_addr[2];
AQ_DBG_ENTER();
@@ -266,13 +266,13 @@ fw1x_get_mac_addr(struct aq_hw* hw, uint8_t* mac)
uint32_t efuse_shadow_addr = AQ_READ_REG(hw, 0x374);
if (efuse_shadow_addr == 0) {
trace_error(dbg_init, "couldn't read eFUSE Shadow Address");
- AQ_DBG_EXIT(-EFAULT);
- return (-EFAULT);
+ AQ_DBG_EXIT(EFAULT);
+ return (EFAULT);
}
err = aq_hw_fw_downld_dwords(hw, efuse_shadow_addr + (40 * 4),
mac_addr, ARRAY_SIZE(mac_addr));
- if (err < 0) {
+ if (err != 0) {
mac_addr[0] = 0;
mac_addr[1] = 0;
AQ_DBG_EXIT(err);
@@ -287,8 +287,8 @@ fw1x_get_mac_addr(struct aq_hw* hw, uint8_t* mac)
trace(dbg_init, "fw1x> eFUSE MAC addr -> %02x-%02x-%02x-%02x-%02x-%02x",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
- AQ_DBG_EXIT(EOK);
- return (EOK);
+ AQ_DBG_EXIT(0);
+ return (0);
}
int
@@ -300,7 +300,7 @@ fw1x_get_stats(struct aq_hw* hw, struct aq_hw_stats_s* stats)
err = aq_hw_fw_downld_dwords(hw, hw->mbox_addr,
(uint32_t*)(void*)&hw->mbox, sizeof hw->mbox / sizeof(uint32_t));
- if (err >= 0) {
+ if (err == 0) {
if (stats != &hw->mbox.stats)
memcpy(stats, &hw->mbox.stats, sizeof *stats);
diff --git a/sys/dev/aq/aq_fw2x.c b/sys/dev/aq/aq_fw2x.c
index 004121242ac1..aee7d80d7013 100644
--- a/sys/dev/aq/aq_fw2x.c
+++ b/sys/dev/aq/aq_fw2x.c
@@ -240,7 +240,7 @@ fw2x_reset(struct aq_hw* hw)
int err = aq_hw_fw_downld_dwords(hw,
hw->mbox_addr + offsetof(fw2x_mailbox, caps),
(uint32_t*)&caps, sizeof caps/sizeof(uint32_t));
- if (err == EOK) {
+ if (err == 0) {
hw->fw_caps = caps.caps_lo | ((uint64_t)caps.caps_hi << 32);
trace(dbg_init,
"fw2x> F/W capabilities mask = %llx",
@@ -250,8 +250,8 @@ fw2x_reset(struct aq_hw* hw)
"fw2x> can't get F/W capabilities mask, error %d", err);
}
- AQ_DBG_EXIT(EOK);
- return (EOK);
+ AQ_DBG_EXIT(err);
+ return (err);
}
@@ -310,12 +310,12 @@ fw2x_set_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state_e mode,
default:
trace_error(dbg_init, "fw2x> unknown MPI state %d", mode);
- return (-EINVAL);
+ return (EINVAL);
}
set_mpi_ctrl_(hw, mpi_ctrl);
- AQ_DBG_EXIT(EOK);
- return (EOK);
+ AQ_DBG_EXIT(0);
+ return (0);
}
int
@@ -355,14 +355,14 @@ fw2x_get_mode(struct aq_hw* hw, enum aq_hw_fw_mpi_state_e* mode,
(32 + CAPS_HI_PAUSE);
// AQ_DBG_EXIT(0);
- return (EOK);
+ return (0);
}
int
fw2x_get_mac_addr(struct aq_hw* hw, uint8_t* mac)
{
- int err = -EFAULT;
+ int err = EFAULT;
uint32_t mac_addr[2];
AQ_DBG_ENTER();
@@ -370,13 +370,13 @@ fw2x_get_mac_addr(struct aq_hw* hw, uint8_t* mac)
uint32_t efuse_shadow_addr = AQ_READ_REG(hw, 0x364);
if (efuse_shadow_addr == 0) {
trace_error(dbg_init, "couldn't read eFUSE Shadow Address");
- AQ_DBG_EXIT(-EFAULT);
- return (-EFAULT);
+ AQ_DBG_EXIT(EFAULT);
+ return (EFAULT);
}
err = aq_hw_fw_downld_dwords(hw, efuse_shadow_addr + (40 * 4), mac_addr,
ARRAY_SIZE(mac_addr));
- if (err < 0) {
+ if (err != 0) {
mac_addr[0] = 0;
mac_addr[1] = 0;
AQ_DBG_EXIT(err);
@@ -388,8 +388,8 @@ fw2x_get_mac_addr(struct aq_hw* hw, uint8_t* mac)
memcpy(mac, (uint8_t*)mac_addr, ETHER_ADDR_LEN);
- AQ_DBG_EXIT(EOK);
- return (EOK);
+ AQ_DBG_EXIT(0);
+ return (0);
}
static inline void
@@ -468,14 +468,14 @@ fw2x_get_stats(struct aq_hw* hw, struct aq_hw_stats_s* stats)
if ((hw->fw_caps & FW2X_CAP_STATISTICS) == 0) {
trace_warn(dbg_fw, "fw2x> statistics not supported by F/W");
- return (-ENOTSUP);
+ return (ENOTSUP);
}
// Tell F/W to update the statistics.
if (!toggle_mpi_ctrl_and_wait_(hw, FW2X_CAP_STATISTICS, 1, 25)) {
trace_error(dbg_fw, "fw2x> statistics update timeout");
- AQ_DBG_EXIT(-ETIME);
- return (-ETIME);
+ AQ_DBG_EXIT(ETIMEDOUT);
+ return (ETIMEDOUT);
}
err = aq_hw_fw_downld_dwords(hw,
@@ -484,7 +484,7 @@ fw2x_get_stats(struct aq_hw* hw, struct aq_hw_stats_s* stats)
fw2x_stats_to_fw_stats_(stats, &fw2x_stats);
- if (err != EOK)
+ if (err != 0)
trace_error(dbg_fw,
"fw2x> download statistics data FAILED, error %d", err);
diff --git a/sys/dev/aq/aq_hw.c b/sys/dev/aq/aq_hw.c
index 3e3e4a9d2f47..f3f47c7ecb1e 100644
--- a/sys/dev/aq/aq_hw.c
+++ b/sys/dev/aq/aq_hw.c
@@ -81,16 +81,16 @@ aq_hw_fw_downld_dwords(struct aq_hw *hw, uint32_t a, uint32_t *p, uint32_t cnt)
int err = 0;
// AQ_DBG_ENTER();
- AQ_HW_WAIT_FOR(reg_glb_cpu_sem_get(hw, AQ_HW_FW_SM_RAM) == 1U, 1U,
+ err = AQ_HW_WAIT_FOR(reg_glb_cpu_sem_get(hw, AQ_HW_FW_SM_RAM) == 1U, 1U,
10000U);
- if (err < 0) {
+ if (err != 0) {
bool is_locked;
reg_glb_cpu_sem_set(hw, 1U, AQ_HW_FW_SM_RAM);
is_locked = reg_glb_cpu_sem_get(hw, AQ_HW_FW_SM_RAM);
if (!is_locked) {
- err = -ETIME;
+ err = ETIMEDOUT;
goto err_exit;
}
}
@@ -101,10 +101,10 @@ aq_hw_fw_downld_dwords(struct aq_hw *hw, uint32_t a, uint32_t *p, uint32_t cnt)
mif_mcp_up_mailbox_execute_operation_set(hw, 1);
if (IS_CHIP_FEATURE(hw, REVISION_B1))
- AQ_HW_WAIT_FOR(a != mif_mcp_up_mailbox_addr_get(hw),
+ err = AQ_HW_WAIT_FOR(a != mif_mcp_up_mailbox_addr_get(hw),
1U, 1000U);
else
- AQ_HW_WAIT_FOR(!mif_mcp_up_mailbox_busy_get(hw), 1,
+ err = AQ_HW_WAIT_FOR(!mif_mcp_up_mailbox_busy_get(hw), 1,
1000U);
*(p++) = mif_mcp_up_mailbox_data_get(hw);
@@ -142,16 +142,16 @@ aq_hw_init_ucp(struct aq_hw *hw)
hw->fw_version.raw = 0;
err = aq_fw_reset(hw);
- if (err != EOK) {
+ if (err != 0) {
aq_log_error("aq_hw_init_ucp(): F/W reset failed, err %d", err);
return (err);
}
aq_hw_chip_features_init(hw, &hw->chip_features);
err = aq_fw_ops_init(hw);
- if (err < 0) {
+ if (err != 0) {
aq_log_error("could not initialize F/W ops, err %d", err);
- return (-1);
+ return (err);
}
if (hw->fw_version.major_version == 1) {
@@ -169,7 +169,7 @@ aq_hw_init_ucp(struct aq_hw *hw)
}
/* check 10 times by 1ms */
- AQ_HW_WAIT_FOR((hw->mbox_addr = AQ_READ_REG(hw, 0x360)) != 0, 400U, 20);
+ err = AQ_HW_WAIT_FOR((hw->mbox_addr = AQ_READ_REG(hw, 0x360)) != 0, 400U, 20);
aq_hw_fw_version ver_expected = { .raw = AQ_CFG_FW_MIN_VER_EXPECTED };
if (!aq_hw_ver_match(&ver_expected, &hw->fw_version))
@@ -187,7 +187,7 @@ aq_hw_mpi_create(struct aq_hw *hw)
AQ_DBG_ENTER();
err = aq_hw_init_ucp(hw);
- if (err < 0)
+ if (err != 0)
goto err_exit;
err_exit:
@@ -204,11 +204,11 @@ aq_hw_mpi_read_stats(struct aq_hw *hw, struct aq_hw_fw_mbox *pmbox)
if (hw->fw_ops && hw->fw_ops->get_stats) {
err = hw->fw_ops->get_stats(hw, &pmbox->stats);
} else {
- err = -ENOTSUP;
+ err = ENOTSUP;
aq_log_error("get_stats() not supported by F/W");
}
- if (err == EOK) {
+ if (err == 0) {
pmbox->stats.dpc = reg_rx_dma_stat_counter7get(hw);
pmbox->stats.cprc = stats_rx_lro_coalesced_pkt_count0_get(hw);
}
@@ -220,7 +220,7 @@ aq_hw_mpi_read_stats(struct aq_hw *hw, struct aq_hw_fw_mbox *pmbox)
static int
aq_hw_mpi_set(struct aq_hw *hw, enum aq_hw_fw_mpi_state_e state, uint32_t speed)
{
- int err = -ENOTSUP;
+ int err = ENOTSUP;
AQ_DBG_ENTERA("speed %d", speed);
if (hw->fw_ops && hw->fw_ops->set_mode) {
@@ -242,7 +242,7 @@ aq_hw_set_link_speed(struct aq_hw *hw, uint32_t speed)
int
aq_hw_get_link_state(struct aq_hw *hw, uint32_t *link_speed, struct aq_hw_fc_info *fc_neg)
{
- int err = EOK;
+ int err = 0;
// AQ_DBG_ENTER();
@@ -254,11 +254,11 @@ aq_hw_get_link_state(struct aq_hw *hw, uint32_t *link_speed, struct aq_hw_fc_inf
err = hw->fw_ops->get_mode(hw, &mode, &speed, &fc);
} else {
aq_log_error("get_mode() not supported by F/W");
- AQ_DBG_EXIT(-ENOTSUP);
- return (-ENOTSUP);
+ AQ_DBG_EXIT(ENOTSUP);
+ return (ENOTSUP);
}
- if (err < 0) {
+ if (err != 0) {
aq_log_error("get_mode() failed, err %d", err);
AQ_DBG_EXIT(err);
return (err);
@@ -298,7 +298,7 @@ aq_hw_get_link_state(struct aq_hw *hw, uint32_t *link_speed, struct aq_hw_fc_inf
int
aq_hw_get_mac_permanent(struct aq_hw *hw, uint8_t *mac)
{
- int err = -ENOTSUP;
+ int err = ENOTSUP;
AQ_DBG_ENTER();
if (hw->fw_ops && hw->fw_ops->get_mac_addr)
@@ -330,7 +330,7 @@ aq_hw_get_mac_permanent(struct aq_hw *hw, uint8_t *mac)
h >>= 8;
mac[0] = (uint8_t)(0xFFU & h);
- err = EOK;
+ err = 0;
}
AQ_DBG_EXIT(err);
@@ -366,15 +366,15 @@ aq_hw_reset(struct aq_hw *hw)
AQ_DBG_ENTER();
err = aq_fw_reset(hw);
- if (err < 0)
+ if (err != 0)
goto err_exit;
itr_irq_reg_res_dis_set(hw, 0);
itr_res_irq_set(hw, 1);
/* check 10 times by 1ms */
- AQ_HW_WAIT_FOR(itr_res_irq_get(hw) == 0, 1000, 10);
- if (err < 0) {
+ err = AQ_HW_WAIT_FOR(itr_res_irq_get(hw) == 0, 1000, 10);
+ if (err != 0) {
printf("atlantic: IRQ reset failed: %d", err);
goto err_exit;
}
@@ -456,21 +456,14 @@ aq_hw_offload_set(struct aq_hw *hw)
/* TX checksums offloads*/
tpo_ipv4header_crc_offload_en_set(hw, 1);
tpo_tcp_udp_crc_offload_en_set(hw, 1);
- if (err < 0)
- goto err_exit;
/* RX checksums offloads*/
rpo_ipv4header_crc_offload_en_set(hw, 1);
rpo_tcp_udp_crc_offload_en_set(hw, 1);
- if (err < 0)
- goto err_exit;
/* LSO offloads*/
tdm_large_send_offload_en_set(hw, 0xFFFFFFFFU);
- if (err < 0)
- goto err_exit;
-/* LRO offloads */
{
uint32_t i = 0;
uint32_t val = (8U < HW_ATL_B0_LRO_RXD_MAX) ? 0x3U :
@@ -505,7 +498,6 @@ aq_hw_offload_set(struct aq_hw *hw)
err = aq_hw_err_from_flags(hw);
-err_exit:
AQ_DBG_EXIT(err);
return (err);
}
@@ -606,7 +598,7 @@ aq_hw_mac_addr_set(struct aq_hw *hw, uint8_t *mac_addr, uint8_t index)
AQ_DBG_ENTER();
if (!mac_addr) {
- err = -EINVAL;
+ err = EINVAL;
goto err_exit;
}
h = (mac_addr[0] << 8) | (mac_addr[1]);
@@ -654,7 +646,7 @@ aq_hw_init(struct aq_hw *hw, uint8_t *mac_addr, uint8_t adm_irq, bool msix)
aq_hw_qos_set(hw);
err = aq_hw_err_from_flags(hw);
- if (err < 0)
+ if (err != 0)
goto err_exit;
/* Interrupts */
@@ -835,9 +827,9 @@ aq_hw_rss_hash_set(struct aq_hw_s *self,
rpf_rss_key_wr_data_set(self, key_data);
rpf_rss_key_addr_set(self, addr);
rpf_rss_key_wr_en_set(self, 1U);
- AQ_HW_WAIT_FOR(rpf_rss_key_wr_en_get(self) == 0,
+ err = AQ_HW_WAIT_FOR(rpf_rss_key_wr_en_get(self) == 0,
1000U, 10U);
- if (err < 0)
+ if (err != 0)
goto err_exit;
}
@@ -899,9 +891,9 @@ aq_hw_rss_set(struct aq_hw_s *self,
rpf_rss_redir_tbl_wr_data_set(self, bitary[i]);
rpf_rss_redir_tbl_addr_set(self, i);
rpf_rss_redir_wr_en_set(self, 1U);
- AQ_HW_WAIT_FOR(rpf_rss_redir_wr_en_get(self) == 0,
+ err = AQ_HW_WAIT_FOR(rpf_rss_redir_wr_en_get(self) == 0,
1000U, 10U);
- if (err < 0)
+ if (err != 0)
goto err_exit;
}
diff --git a/sys/dev/aq/aq_main.c b/sys/dev/aq/aq_main.c
index ebe8b13da795..fd278826bd2d 100644
--- a/sys/dev/aq/aq_main.c
+++ b/sys/dev/aq/aq_main.c
@@ -363,7 +363,7 @@ aq_if_attach_pre(if_ctx_t ctx)
/* Look up ops and caps. */
rc = aq_hw_mpi_create(hw);
- if (rc < 0) {
+ if (rc != 0) {
AQ_DBG_ERROR(" %s: aq_hw_mpi_create fail err=%d", __func__, rc);
goto fail;
}
@@ -375,10 +375,11 @@ aq_if_attach_pre(if_ctx_t ctx)
aq_hw_reset(&softc->hw);
aq_hw_capabilities(softc);
- if (aq_hw_get_mac_permanent(hw, hw->mac_addr) < 0) {
+ rc = aq_hw_get_mac_permanent(hw, hw->mac_addr);
+ if (rc != 0) {
AQ_DBG_ERROR("Unable to get mac addr from hw");
goto fail;
- };
+ }
softc->admin_ticks = 0;
@@ -417,7 +418,11 @@ aq_if_attach_pre(if_ctx_t ctx)
/* iflib will map and release this bar */
scctx->isc_msix_bar = pci_msix_table_bar(softc->dev);
- softc->vlan_tags = bit_alloc(4096, M_AQ, M_NOWAIT);
+ softc->vlan_tags = bit_alloc(4096, M_AQ, M_NOWAIT);
+ if (softc->vlan_tags == NULL) {
+ rc = ENOMEM;
+ goto fail;
+ }
AQ_DBG_EXIT(rc);
return (rc);
@@ -428,7 +433,7 @@ fail:
softc->mmio_rid, softc->mmio_res);
AQ_DBG_EXIT(rc);
- return (ENXIO);
+ return (rc);
}
@@ -672,7 +677,7 @@ aq_if_init(if_ctx_t ctx)
err = aq_hw_init(&softc->hw, softc->hw.mac_addr, softc->msix,
softc->scctx->isc_intr == IFLIB_INTR_MSIX);
- if (err != EOK) {
+ if (err != 0) {
device_printf(softc->dev, "atlantic: aq_hw_init: %d", err);
}
@@ -688,7 +693,7 @@ aq_if_init(if_ctx_t ctx)
"atlantic: aq_ring_tx_init: %d", err);
}
err = aq_ring_tx_start(hw, ring);
- if (err != EOK) {
+ if (err != 0) {
device_printf(softc->dev,
"atlantic: aq_ring_tx_start: %d", err);
}
@@ -701,7 +706,7 @@ aq_if_init(if_ctx_t ctx)
"atlantic: aq_ring_rx_init: %d", err);
}
err = aq_ring_rx_start(hw, ring);
- if (err != EOK) {
+ if (err != 0) {
device_printf(softc->dev,
"atlantic: aq_ring_rx_start: %d", err);
}