diff mbox series

[net-next,v2,1/2] net: qed_ptp: fix redundant check of rc and against -EINVAL

Message ID 927234fe6f6d9d50b9803e57bb370f97342ae2f0.1634847661.git.sakiwit@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series Small fixes for redundant checks | expand

Checks

Context Check Description
netdev/cover_letter success Series has a cover letter
netdev/fixes_present success Fixes tag not required for -next series
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success No Fixes tag
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 28 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success No static functions without inline keyword in header files

Commit Message

Jεan Sacren Oct. 22, 2021, 3:37 a.m. UTC
From: Jean Sacren <sakiwit@gmail.com>

We should first check rc alone and then check it against -EINVAL to
avoid repeating the same operation.

We should also remove the check of !rc in (!rc && !params.b_granted)
since it is always true.

With this change, we could also use constant 0 for return.

Signed-off-by: Jean Sacren <sakiwit@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
---
v2:
(1) Add text for !rc removal in the changelog.
(2) Add Reviewed-by tag of Mr. Simon Horman.
 drivers/net/ethernet/qlogic/qed/qed_ptp.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

Prabhakar Kushwaha Oct. 22, 2021, 5:27 a.m. UTC | #1
> -----Original Message-----
> From: Jεan Sacren <sakiwit@gmail.com>
> Sent: Friday, October 22, 2021 9:08 AM
> To: Ariel Elior <aelior@marvell.com>
> Cc: GR-everest-linux-l2 <GR-everest-linux-l2@marvell.com>;
> davem@davemloft.net; kuba@kernel.org; netdev@vger.kernel.org
> Subject: [EXT] [PATCH net-next v2 1/2] net: qed_ptp: fix redundant check of rc
> and against -EINVAL
> 
> External Email
> 
> ----------------------------------------------------------------------
> From: Jean Sacren <sakiwit@gmail.com>
> 
> We should first check rc alone and then check it against -EINVAL to
> avoid repeating the same operation.
> 
> We should also remove the check of !rc in (!rc && !params.b_granted)
> since it is always true.
> 
> With this change, we could also use constant 0 for return.
> 
> Signed-off-by: Jean Sacren <sakiwit@gmail.com>
> Reviewed-by: Simon Horman <horms@kernel.org>
> ---

Acked-by: Prabhakar Kushwaha <pkushwaha@marvell.com>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/qlogic/qed/qed_ptp.c b/drivers/net/ethernet/qlogic/qed/qed_ptp.c
index 2c62d732e5c2..c927ff409109 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_ptp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_ptp.c
@@ -52,9 +52,9 @@  static int qed_ptp_res_lock(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
 	qed_mcp_resc_lock_default_init(&params, NULL, resource, true);
 
 	rc = qed_mcp_resc_lock(p_hwfn, p_ptt, &params);
-	if (rc && rc != -EINVAL) {
-		return rc;
-	} else if (rc == -EINVAL) {
+	if (rc) {
+		if (rc != -EINVAL)
+			return rc;
 		/* MFW doesn't support resource locking, first PF on the port
 		 * has lock ownership.
 		 */
@@ -63,12 +63,14 @@  static int qed_ptp_res_lock(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
 
 		DP_INFO(p_hwfn, "PF doesn't have lock ownership\n");
 		return -EBUSY;
-	} else if (!rc && !params.b_granted) {
+	}
+
+	if (!params.b_granted) {
 		DP_INFO(p_hwfn, "Failed to acquire ptp resource lock\n");
 		return -EBUSY;
 	}
 
-	return rc;
+	return 0;
 }
 
 static int qed_ptp_res_unlock(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)