From: Simon Horman <horms@kernel.org>
To: "Jεan Sacren" <sakiwit@gmail.com>
Cc: Ariel Elior <aelior@marvell.com>,
GR-everest-linux-l2@marvell.com, davem@davemloft.net,
kuba@kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH net-next 1/2] net: qed_ptp: fix redundant check of rc and against -EINVAL
Date: Wed, 20 Oct 2021 10:48:35 +0200 [thread overview]
Message-ID: <20211020084835.GB3935@kernel.org> (raw)
In-Reply-To: <492df79e1ae204ec455973e22002ca2c62c41d1e.1634621525.git.sakiwit@gmail.com>
On Tue, Oct 19, 2021 at 12:26:41AM -0600, Jεan Sacren wrote:
> From: Jean Sacren <sakiwit@gmail.com>
>
> We should first check rc alone and then check it against -EINVAL to
> avoid repeating the same operation.
>
> With this change, we could also use constant 0 for return.
>
> Signed-off-by: Jean Sacren <sakiwit@gmail.com>
> ---
> drivers/net/ethernet/qlogic/qed/qed_ptp.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> 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(¶ms, NULL, resource, true);
>
> rc = qed_mcp_resc_lock(p_hwfn, p_ptt, ¶ms);
> - 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) {
Can it be the case where the condition above is met and !rc is false?
If so your patch seems to have changed the logic of this function.
> 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)
>
next prev parent reply other threads:[~2021-10-20 8:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-19 6:26 [PATCH net-next 0/2] Small fixes for redundant checks Jεan Sacren
2021-10-19 6:26 ` [PATCH net-next 1/2] net: qed_ptp: fix redundant check of rc and against -EINVAL Jεan Sacren
2021-10-20 8:48 ` Simon Horman [this message]
2021-10-21 7:35 ` Jεan Sacren
2021-10-21 10:46 ` Simon Horman
2021-10-19 6:26 ` [PATCH net-next 2/2] net: qed_dev: " Jεan Sacren
2021-10-20 8:47 ` Simon Horman
2021-10-21 7:36 ` Jεan Sacren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211020084835.GB3935@kernel.org \
--to=horms@kernel.org \
--cc=GR-everest-linux-l2@marvell.com \
--cc=aelior@marvell.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sakiwit@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).