c76e0d
From 5467767d34d64cf07212f35683495ffb82ca7b10 Mon Sep 17 00:00:00 2001
c76e0d
From: Mark Starovoytov <mstarovoitov@marvell.com>
c76e0d
Date: Fri, 17 Jul 2020 21:01:46 +0300
c76e0d
Subject: [PATCH 01/13] net: atlantic: align return value of ver_match function
c76e0d
 with function name
c76e0d
Patch-mainline: v5.9-rc1
c76e0d
Git-commit: b567edbfc85ac375181862808928aeb381560c68
33bcfb
References: jsc#SLE-15148
c76e0d
c76e0d
This patch aligns the return value of hw_atl_utils_ver_match function with
c76e0d
its name.
c76e0d
Change the return type to bool, because it's better aligned with the actual
c76e0d
usage. Return true when the version matches, false otherwise.
c76e0d
c76e0d
Signed-off-by: Mark Starovoytov <mstarovoitov@marvell.com>
c76e0d
Signed-off-by: Igor Russkikh <irusskikh@marvell.com>
c76e0d
Signed-off-by: David S. Miller <davem@davemloft.net>
c76e0d
Acked-by: Denis Kirjanov <denis.kirjanov@suse.com>
c76e0d
---
c76e0d
 .../aquantia/atlantic/hw_atl/hw_atl_utils.c        | 29 ++++++++++------------
c76e0d
 .../aquantia/atlantic/hw_atl/hw_atl_utils.h        |  2 +-
c76e0d
 .../aquantia/atlantic/hw_atl2/hw_atl2_utils.c      |  3 +--
c76e0d
 3 files changed, 15 insertions(+), 19 deletions(-)
c76e0d
c76e0d
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
c76e0d
index bf4c41cc312b..22f68e4a638c 100644
c76e0d
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
c76e0d
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
c76e0d
@@ -72,14 +72,11 @@ int hw_atl_utils_initfw(struct aq_hw_s *self, const struct aq_fw_ops **fw_ops)
c76e0d
 
c76e0d
 	self->fw_ver_actual = hw_atl_utils_get_fw_version(self);
c76e0d
 
c76e0d
-	if (hw_atl_utils_ver_match(HW_ATL_FW_VER_1X,
c76e0d
-				   self->fw_ver_actual) == 0) {
c76e0d
+	if (hw_atl_utils_ver_match(HW_ATL_FW_VER_1X, self->fw_ver_actual)) {
c76e0d
 		*fw_ops = &aq_fw_1x_ops;
c76e0d
-	} else if (hw_atl_utils_ver_match(HW_ATL_FW_VER_2X,
c76e0d
-					  self->fw_ver_actual) == 0) {
c76e0d
+	} else if (hw_atl_utils_ver_match(HW_ATL_FW_VER_2X, self->fw_ver_actual)) {
c76e0d
 		*fw_ops = &aq_fw_2x_ops;
c76e0d
-	} else if (hw_atl_utils_ver_match(HW_ATL_FW_VER_3X,
c76e0d
-					  self->fw_ver_actual) == 0) {
c76e0d
+	} else if (hw_atl_utils_ver_match(HW_ATL_FW_VER_3X, self->fw_ver_actual)) {
c76e0d
 		*fw_ops = &aq_fw_2x_ops;
c76e0d
 	} else {
c76e0d
 		aq_pr_err("Bad FW version detected: %x\n",
c76e0d
@@ -262,9 +259,9 @@ int hw_atl_utils_soft_reset(struct aq_hw_s *self)
c76e0d
 	/* FW 1.x may bootup in an invalid POWER state (WOL feature).
c76e0d
 	 * We should work around this by forcing its state back to DEINIT
c76e0d
 	 */
c76e0d
-	if (!hw_atl_utils_ver_match(HW_ATL_FW_VER_1X,
c76e0d
-				    aq_hw_read_reg(self,
c76e0d
-						   HW_ATL_MPI_FW_VERSION))) {
c76e0d
+	if (hw_atl_utils_ver_match(HW_ATL_FW_VER_1X,
c76e0d
+				   aq_hw_read_reg(self,
c76e0d
+						  HW_ATL_MPI_FW_VERSION))) {
c76e0d
 		int err = 0;
c76e0d
 
c76e0d
 		hw_atl_utils_mpi_set_state(self, MPI_DEINIT);
c76e0d
@@ -434,20 +431,20 @@ int hw_atl_write_fwsettings_dwords(struct aq_hw_s *self, u32 offset, u32 *p,
c76e0d
 					     p, cnt, MCP_AREA_SETTINGS);
c76e0d
 }
c76e0d
 
c76e0d
-int hw_atl_utils_ver_match(u32 ver_expected, u32 ver_actual)
c76e0d
+bool hw_atl_utils_ver_match(u32 ver_expected, u32 ver_actual)
c76e0d
 {
c76e0d
 	const u32 dw_major_mask = 0xff000000U;
c76e0d
 	const u32 dw_minor_mask = 0x00ffffffU;
c76e0d
-	int err = 0;
c76e0d
+	bool ver_match;
c76e0d
 
c76e0d
-	err = (dw_major_mask & (ver_expected ^ ver_actual)) ? -EOPNOTSUPP : 0;
c76e0d
-	if (err < 0)
c76e0d
+	ver_match = (dw_major_mask & (ver_expected ^ ver_actual)) ? false : true;
c76e0d
+	if (!ver_match)
c76e0d
 		goto err_exit;
c76e0d
-	err = ((dw_minor_mask & ver_expected) > (dw_minor_mask & ver_actual)) ?
c76e0d
-		-EOPNOTSUPP : 0;
c76e0d
+	ver_match = ((dw_minor_mask & ver_expected) > (dw_minor_mask & ver_actual)) ?
c76e0d
+		false : true;
c76e0d
 
c76e0d
 err_exit:
c76e0d
-	return err;
c76e0d
+	return ver_match;
c76e0d
 }
c76e0d
 
c76e0d
 static int hw_atl_utils_init_ucp(struct aq_hw_s *self,
c76e0d
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
c76e0d
index 56486ebfca06..27146dd612b3 100644
c76e0d
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h
c76e0d
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h
c76e0d
@@ -600,7 +600,7 @@ int hw_atl_utils_fw_rpc_call(struct aq_hw_s *self, unsigned int rpc_size);
c76e0d
 int hw_atl_utils_fw_rpc_wait(struct aq_hw_s *self,
c76e0d
 			     struct hw_atl_utils_fw_rpc **rpc);
c76e0d
 
c76e0d
-int hw_atl_utils_ver_match(u32 ver_expected, u32 ver_actual);
c76e0d
+bool hw_atl_utils_ver_match(u32 ver_expected, u32 ver_actual);
c76e0d
 
c76e0d
 extern const struct aq_fw_ops aq_fw_1x_ops;
c76e0d
 extern const struct aq_fw_ops aq_fw_2x_ops;
c76e0d
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.c
c76e0d
index f3766780e975..0fe6257d9c08 100644
c76e0d
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.c
c76e0d
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils.c
c76e0d
@@ -36,8 +36,7 @@ int hw_atl2_utils_initfw(struct aq_hw_s *self, const struct aq_fw_ops **fw_ops)
c76e0d
 
c76e0d
 	self->fw_ver_actual = hw_atl2_utils_get_fw_version(self);
c76e0d
 
c76e0d
-	if (hw_atl_utils_ver_match(HW_ATL2_FW_VER_1X,
c76e0d
-				   self->fw_ver_actual) == 0) {
c76e0d
+	if (hw_atl_utils_ver_match(HW_ATL2_FW_VER_1X, self->fw_ver_actual)) {
c76e0d
 		*fw_ops = &aq_a2_fw_ops;
c76e0d
 	} else {
c76e0d
 		aq_pr_err("Bad FW version detected: %x, but continue\n",
c76e0d
-- 
c76e0d
2.16.4
c76e0d