[F] [PATCH 2/3] net: atlantic: align return value of ver_match function with function name
Kai-Heng Feng
kai.heng.feng at canonical.com
Thu Jul 23 16:39:01 UTC 2020
From: Mark Starovoytov <mstarovoitov at marvell.com>
BugLink: https://bugs.launchpad.net/bugs/1886908
This patch aligns the return value of hw_atl_utils_ver_match function with
its name.
Change the return type to bool, because it's better aligned with the actual
usage. Return true when the version matches, false otherwise.
Signed-off-by: Mark Starovoytov <mstarovoitov at marvell.com>
Signed-off-by: Igor Russkikh <irusskikh at marvell.com>
Signed-off-by: David S. Miller <davem at davemloft.net>
(backported from commit b567edbfc85ac375181862808928aeb381560c68 linux-next)
Signed-off-by: Kai-Heng Feng <kai.heng.feng at canonical.com>
---
.../aquantia/atlantic/hw_atl/hw_atl_utils.c | 96 +++++++++----------
.../aquantia/atlantic/hw_atl/hw_atl_utils.h | 2 +
2 files changed, 49 insertions(+), 49 deletions(-)
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
index b63521bf9d8d..de6f9c9f7b4a 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
@@ -48,9 +48,8 @@
#define FORCE_FLASHLESS 0
-static int hw_atl_utils_ver_match(u32 ver_expected, u32 ver_actual);
static int hw_atl_utils_mpi_set_state(struct aq_hw_s *self,
- enum hal_atl_utils_fw_state_e state);
+ enum hal_atl_utils_fw_state_e state);
static u32 hw_atl_utils_get_mpi_mbox_tid(struct aq_hw_s *self);
static u32 hw_atl_utils_mpi_get_state(struct aq_hw_s *self);
static u32 hw_atl_utils_mif_cmd_get(struct aq_hw_s *self);
@@ -67,22 +66,19 @@ int hw_atl_utils_initfw(struct aq_hw_s *self, const struct aq_fw_ops **fw_ops)
return err;
hw_atl_utils_hw_chip_features_init(self,
- &self->chip_features);
+ &self->chip_features);
self->fw_ver_actual = hw_atl_utils_get_fw_version(self);
- if (hw_atl_utils_ver_match(HW_ATL_FW_VER_1X,
- self->fw_ver_actual) == 0) {
+ if (hw_atl_utils_ver_match(HW_ATL_FW_VER_1X, self->fw_ver_actual)) {
*fw_ops = &aq_fw_1x_ops;
- } else if (hw_atl_utils_ver_match(HW_ATL_FW_VER_2X,
- self->fw_ver_actual) == 0) {
+ } else if (hw_atl_utils_ver_match(HW_ATL_FW_VER_2X, self->fw_ver_actual)) {
*fw_ops = &aq_fw_2x_ops;
- } else if (hw_atl_utils_ver_match(HW_ATL_FW_VER_3X,
- self->fw_ver_actual) == 0) {
+ } else if (hw_atl_utils_ver_match(HW_ATL_FW_VER_3X, self->fw_ver_actual)) {
*fw_ops = &aq_fw_2x_ops;
} else {
aq_pr_err("Bad FW version detected: %x\n",
- self->fw_ver_actual);
+ self->fw_ver_actual);
return -EOPNOTSUPP;
}
self->aq_fw_ops = *fw_ops;
@@ -121,7 +117,7 @@ static int hw_atl_utils_soft_reset_flb(struct aq_hw_s *self)
for (k = 0; k < 1000; k++) {
u32 flb_status = aq_hw_read_reg(self,
- HW_ATL_MPI_DAISY_CHAIN_STATUS);
+ HW_ATL_MPI_DAISY_CHAIN_STATUS);
flb_status = flb_status & 0x10;
if (flb_status)
@@ -144,8 +140,8 @@ static int hw_atl_utils_soft_reset_flb(struct aq_hw_s *self)
hw_atl_rx_rx_reg_res_dis_set(self, 0U);
hw_atl_tx_tx_reg_res_dis_set(self, 0U);
aq_hw_write_reg_bit(self, HW_ATL_MAC_PHY_CONTROL,
- BIT(HW_ATL_MAC_PHY_MPI_RESET_BIT),
- HW_ATL_MAC_PHY_MPI_RESET_BIT, 0x0);
+ BIT(HW_ATL_MAC_PHY_MPI_RESET_BIT),
+ HW_ATL_MAC_PHY_MPI_RESET_BIT, 0x0);
gsr = aq_hw_read_reg(self, HW_ATL_GLB_SOFT_RES_ADR);
aq_hw_write_reg(self, HW_ATL_GLB_SOFT_RES_ADR, (gsr & 0xBFFF) | 0x8000);
@@ -186,8 +182,8 @@ static int hw_atl_utils_soft_reset_rbl(struct aq_hw_s *self)
hw_atl_rx_rx_reg_res_dis_set(self, 0U);
hw_atl_tx_tx_reg_res_dis_set(self, 0U);
aq_hw_write_reg_bit(self, HW_ATL_MAC_PHY_CONTROL,
- BIT(HW_ATL_MAC_PHY_MPI_RESET_BIT),
- HW_ATL_MAC_PHY_MPI_RESET_BIT, 0x0);
+ BIT(HW_ATL_MAC_PHY_MPI_RESET_BIT),
+ HW_ATL_MAC_PHY_MPI_RESET_BIT, 0x0);
gsr = aq_hw_read_reg(self, HW_ATL_GLB_SOFT_RES_ADR);
aq_hw_write_reg(self, HW_ATL_GLB_SOFT_RES_ADR,
(gsr & 0xFFFFBFFF) | 0x8000);
@@ -243,9 +239,9 @@ int hw_atl_utils_soft_reset(struct aq_hw_s *self)
for (k = 0; k < 1000; ++k) {
u32 flb_status = aq_hw_read_reg(self,
- HW_ATL_MPI_DAISY_CHAIN_STATUS);
+ HW_ATL_MPI_DAISY_CHAIN_STATUS);
boot_exit_code = aq_hw_read_reg(self,
- HW_ATL_MPI_BOOT_EXIT_CODE);
+ HW_ATL_MPI_BOOT_EXIT_CODE);
if (flb_status != 0x06000000 || boot_exit_code != 0)
break;
}
@@ -260,17 +256,17 @@ int hw_atl_utils_soft_reset(struct aq_hw_s *self)
/* FW 1.x may bootup in an invalid POWER state (WOL feature).
* We should work around this by forcing its state back to DEINIT
*/
- if (!hw_atl_utils_ver_match(HW_ATL_FW_VER_1X,
- aq_hw_read_reg(self,
- HW_ATL_MPI_FW_VERSION))) {
+ if (hw_atl_utils_ver_match(HW_ATL_FW_VER_1X,
+ aq_hw_read_reg(self,
+ HW_ATL_MPI_FW_VERSION))) {
int err = 0;
hw_atl_utils_mpi_set_state(self, MPI_DEINIT);
err = readx_poll_timeout_atomic(hw_atl_utils_mpi_get_state,
- self, val,
- (val & HW_ATL_MPI_STATE_MSK) ==
- MPI_DEINIT,
- 10, 10000U);
+ self, val,
+ (val & HW_ATL_MPI_STATE_MSK) ==
+ MPI_DEINIT,
+ 10, 10000U);
if (err)
return err;
}
@@ -282,14 +278,14 @@ int hw_atl_utils_soft_reset(struct aq_hw_s *self)
}
int hw_atl_utils_fw_downld_dwords(struct aq_hw_s *self, u32 a,
- u32 *p, u32 cnt)
+ u32 *p, u32 cnt)
{
int err = 0;
u32 val;
err = readx_poll_timeout_atomic(hw_atl_sem_ram_get,
- self, val, val == 1U,
- 1U, 10000U);
+ self, val, val == 1U,
+ 1U, 10000U);
if (err < 0) {
bool is_locked;
@@ -309,13 +305,13 @@ int hw_atl_utils_fw_downld_dwords(struct aq_hw_s *self, u32 a,
if (IS_CHIP_FEATURE(REVISION_B1))
err = readx_poll_timeout_atomic(hw_atl_utils_mif_addr_get,
- self, val, val != a,
- 1U, 1000U);
+ self, val, val != a,
+ 1U, 1000U);
else
err = readx_poll_timeout_atomic(hw_atl_utils_mif_cmd_get,
- self, val,
- !(val & 0x100),
- 1U, 1000U);
+ self, val,
+ !(val & 0x100),
+ 1U, 1000U);
*(p++) = aq_hw_read_reg(self, HW_ATL_MIF_VAL);
a += 4;
@@ -328,14 +324,14 @@ int hw_atl_utils_fw_downld_dwords(struct aq_hw_s *self, u32 a,
}
static int hw_atl_utils_fw_upload_dwords(struct aq_hw_s *self, u32 a, u32 *p,
- u32 cnt)
+ u32 cnt)
{
u32 val;
int err = 0;
err = readx_poll_timeout_atomic(hw_atl_sem_ram_get, self,
- val, val == 1U,
- 10U, 100000U);
+ val, val == 1U,
+ 10U, 100000U);
if (err < 0)
goto err_exit;
@@ -349,10 +345,10 @@ static int hw_atl_utils_fw_upload_dwords(struct aq_hw_s *self, u32 a, u32 *p,
hw_atl_mcp_up_force_intr_set(self, 1);
/* 1000 times by 10us = 10ms */
err = readx_poll_timeout_atomic(hw_atl_scrpad12_get,
- self, val,
- (val & 0xF0000000) !=
- 0x80000000,
- 10U, 10000U);
+ self, val,
+ (val & 0xF0000000) !=
+ 0x80000000,
+ 10U, 10000U);
}
} else {
u32 offset = 0;
@@ -364,9 +360,9 @@ static int hw_atl_utils_fw_upload_dwords(struct aq_hw_s *self, u32 a, u32 *p,
aq_hw_write_reg(self, 0x200, 0xC000);
err = readx_poll_timeout_atomic(hw_atl_utils_mif_cmd_get,
- self, val,
- (val & 0x100) == 0,
- 1000U, 10000U);
+ self, val,
+ (val & 0x100) == 0,
+ 1000U, 10000U);
}
}
@@ -376,19 +372,21 @@ static int hw_atl_utils_fw_upload_dwords(struct aq_hw_s *self, u32 a, u32 *p,
return err;
}
-static int hw_atl_utils_ver_match(u32 ver_expected, u32 ver_actual)
+bool hw_atl_utils_ver_match(u32 ver_expected, u32 ver_actual)
{
- int err = 0;
const u32 dw_major_mask = 0xff000000U;
const u32 dw_minor_mask = 0x00ffffffU;
+ bool ver_match;
- err = (dw_major_mask & (ver_expected ^ ver_actual)) ? -EOPNOTSUPP : 0;
- if (err < 0)
+ ver_match = (dw_major_mask & (ver_expected ^ ver_actual)) ? false : true;
+ if (!ver_match)
goto err_exit;
- err = ((dw_minor_mask & ver_expected) > (dw_minor_mask & ver_actual)) ?
- -EOPNOTSUPP : 0;
+
+ ver_match = ((dw_minor_mask & ver_expected) > (dw_minor_mask & ver_actual)) ?
+ false : true;
+
err_exit:
- return err;
+ return ver_match;
}
static int hw_atl_utils_init_ucp(struct aq_hw_s *self,
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h
index 7cf45835afa6..c8862df58631 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h
@@ -482,6 +482,8 @@ int hw_atl_utils_fw_rpc_call(struct aq_hw_s *self, unsigned int rpc_size);
int hw_atl_utils_fw_rpc_wait(struct aq_hw_s *self,
struct hw_atl_utils_fw_rpc **rpc);
+bool hw_atl_utils_ver_match(u32 ver_expected, u32 ver_actual);
+
extern const struct aq_fw_ops aq_fw_1x_ops;
extern const struct aq_fw_ops aq_fw_2x_ops;
--
2.17.1
More information about the kernel-team
mailing list