From patchwork Tue Oct 19 06:26:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?J=CE=B5an_Sacren?= X-Patchwork-Id: 12568681 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEFB6C433EF for ; Tue, 19 Oct 2021 06:26:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 918D7611BF for ; Tue, 19 Oct 2021 06:26:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233717AbhJSG3C (ORCPT ); Tue, 19 Oct 2021 02:29:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234267AbhJSG3C (ORCPT ); Tue, 19 Oct 2021 02:29:02 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CDFFC06161C for ; Mon, 18 Oct 2021 23:26:49 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id u8-20020a05600c440800b0030d90076dabso1283096wmn.1 for ; Mon, 18 Oct 2021 23:26:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=T3GJaGUMRU1cUcoEx8S8pRg7CxWQBhMFdydRT7Nj9P0=; b=DvMUK73nVtN8p4hmizLqdXAhdXx06s6iVfuUir2/t6AJi4USmbBCRKqxdGQ0oEkCP2 /gEloT8BrbgBy/TkS3d4Nmm3jbUTi8NB9o5+pbXXz5cC5NFDINUURogOVvzUQdp/FYKc WiJS6MrA13+5tH2+e8HebZblNf41lDXF2G9H21T5I8caegQhLWnG7eLZx6SGxOYwml/s HwVJfl8cP0QoTx7Ny7WSK4U398HoYzXNOrlg4t3ODlZu+ZjUDg6zz+vhy5cuBH+0dKCL dmQtBA/kdbbZV/fl0bG3I7k3grsBi0MXko9Dx2i24XcOMjJpa5gZdGn9ypBmPYFLiOSj xFMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T3GJaGUMRU1cUcoEx8S8pRg7CxWQBhMFdydRT7Nj9P0=; b=GcnjrWV2FAouyORTtanvFaD+emAmU7B1h1GdzxnYFoCa8RC1AA6VjCUl9EITArrkif YHfjV1SXUgM+5jXshL/8LUVkCUCFwPi2pFCpmPUDkMlLvJNDX5FJtwBZCWc0qyJfYWGi 3QfH4F+qxOIwRkEfv5aSz4FK9jCLpVEEwnsfrn1S9cMqtL8qmja3HomHEggi+Q/0yo+U wZJm7vZ1PrX1oOjSVYoJ61qjkQxAnIqAh5c98ual3I3vrMTOor//w97JMyd8RvrjOrqK ux7bqcJeHSDZccTq109JUh24TPfBDmjhl5cc2/ajJd9dWDp10fe6BX2EBcqgvwfkVEFi 9wIg== X-Gm-Message-State: AOAM5330W4Z/zzdFN/whF11OlApJdbGQyce6AOvhgipndq1EJ6dzYpQ6 6MFpqkJBvR93mMF6OrMKqKVo0Yckzs8uXw== X-Google-Smtp-Source: ABdhPJzran8eQR0cC9bzcQ9SGzbLTYgrsCS+3IKm1p05qltsR458UthsYbEYNMVP2o99pI2wYwe09A== X-Received: by 2002:a1c:7918:: with SMTP id l24mr3859096wme.137.1634624808272; Mon, 18 Oct 2021 23:26:48 -0700 (PDT) Received: from localhost (tor-exit-15.zbau.f3netze.de. [185.220.100.242]) by smtp.gmail.com with ESMTPSA id y8sm1261287wmi.43.2021.10.18.23.26.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 23:26:47 -0700 (PDT) From: =?utf-8?q?J=CE=B5an_Sacren?= To: Ariel Elior Cc: GR-everest-linux-l2@marvell.com, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next 1/2] net: qed_ptp: fix redundant check of rc and against -EINVAL Date: Tue, 19 Oct 2021 00:26:41 -0600 Message-Id: <492df79e1ae204ec455973e22002ca2c62c41d1e.1634621525.git.sakiwit@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Jean Sacren 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 Reviewed-by: Simon Horman --- 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) { 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) From patchwork Tue Oct 19 06:26:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?J=CE=B5an_Sacren?= X-Patchwork-Id: 12568683 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A696C433F5 for ; Tue, 19 Oct 2021 06:26:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2C15A610A1 for ; Tue, 19 Oct 2021 06:26:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234267AbhJSG3J (ORCPT ); Tue, 19 Oct 2021 02:29:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234207AbhJSG3I (ORCPT ); Tue, 19 Oct 2021 02:29:08 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E557C06161C for ; Mon, 18 Oct 2021 23:26:56 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id o24so3377783wms.0 for ; Mon, 18 Oct 2021 23:26:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QIJSC3yJ+j+xGb3nbulYCDNwXu8i/S4uRwQ3RzYL4aA=; b=cr/K6ksQTDcyNpzngSb0y7WXOFgje/c0oVfi75EYSPOzOKeBpSVUiUqQJK49Lslm1P p94MpthP59I4hTIeaGPetClccpJPw3WRvlEbLWusfG6Ua1IUcClJJRYI4mZirLDc3qOA zJCn9C4SvmTKRhj+Q+PVPG2GELsVu5lARQC9LN1cbiYrz+VPdtaLJY//ygJL4KWCcw/l A+OSqH2IMPsz5eVrnxLjx+1rhfWRFz6ERDNh6cJj5gZB+wsgruy25Sw556Ku/NxX6deq 0JivIKfoE5P0URot1zVqDbTn2JIuYmqVjfeDJiiEDvAG6JKfbE6Ls+UHhwnsixJL3bcw Y9ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QIJSC3yJ+j+xGb3nbulYCDNwXu8i/S4uRwQ3RzYL4aA=; b=AlhVn5m7ayKn+8h18B40G23MHbuUEWlXJnwHW3nv4ciFXU6vYxAGP7XDTeuqdlmTyr PkuaPJxtyHuXTU6NTyud15iGuoIe+agtpcmHbx9pk7bPYcRB7lJJMKOtxohGd378RL+Z wJku2SuKcpvdLnP3+UUv5gSRHjvnpoSUmpOUCn2SMt7bAKl7fTEW8fcj3+kfuaWk7iuc +33vnte2GR2WIUP73v+F7bbfPMBWR3xIK4Lt4usYcdxZNrWqJ4/JoUEE1qvMGZbmwT8L tlkHtj7JorgS4w/zjhp7WHQqpLQBaRezbme7p59YKOjkQlWm1cF51oDEwgMSm9lbQLqU 5M2g== X-Gm-Message-State: AOAM533poTE9LpP6yHgD3Ct7lEYNTy7yeazZ4fcT8zssXW2jOLw/8bx7 nN+U3NOal6xgs+x4jJ4b6lY= X-Google-Smtp-Source: ABdhPJxNTgaJxNi+NYbu1ooEu0hA6tfhIuiJSjtpQaD2WFX8GMnbLpQJIeWc+Xc8D4Px8UE8j5QvTA== X-Received: by 2002:a1c:44c:: with SMTP id 73mr3877874wme.45.1634624815012; Mon, 18 Oct 2021 23:26:55 -0700 (PDT) Received: from localhost (tor-exit-15.zbau.f3netze.de. [185.220.100.242]) by smtp.gmail.com with ESMTPSA id p11sm1630118wmi.0.2021.10.18.23.26.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 23:26:54 -0700 (PDT) From: =?utf-8?q?J=CE=B5an_Sacren?= To: Ariel Elior Cc: GR-everest-linux-l2@marvell.com, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next 2/2] net: qed_dev: fix redundant check of rc and against -EINVAL Date: Tue, 19 Oct 2021 00:26:42 -0600 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Jean Sacren We should first check rc alone and then check it against -EINVAL to avoid repeating the same operation multiple times. Signed-off-by: Jean Sacren --- drivers/net/ethernet/qlogic/qed/qed_dev.c | 35 +++++++++++++---------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c b/drivers/net/ethernet/qlogic/qed/qed_dev.c index 18f3bf7c4dfe..fe8bdb4523b5 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_dev.c +++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c @@ -3987,30 +3987,35 @@ static int qed_hw_get_resc(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) QED_RESC_LOCK_RESC_ALLOC, false); rc = qed_mcp_resc_lock(p_hwfn, p_ptt, &resc_lock_params); - if (rc && rc != -EINVAL) { - return rc; - } else if (rc == -EINVAL) { + if (rc) { + if (rc != -EINVAL) + return rc; + DP_INFO(p_hwfn, "Skip the max values setting of the soft resources since the resource lock is not supported by the MFW\n"); - } else if (!rc && !resc_lock_params.b_granted) { + } + + if (!resc_lock_params.b_granted) { DP_NOTICE(p_hwfn, "Failed to acquire the resource lock for the resource allocation commands\n"); return -EBUSY; - } else { - rc = qed_hw_set_soft_resc_size(p_hwfn, p_ptt); - if (rc && rc != -EINVAL) { + } + + rc = qed_hw_set_soft_resc_size(p_hwfn, p_ptt); + if (rc) { + if (rc != -EINVAL) { DP_NOTICE(p_hwfn, "Failed to set the max values of the soft resources\n"); goto unlock_and_exit; - } else if (rc == -EINVAL) { - DP_INFO(p_hwfn, - "Skip the max values setting of the soft resources since it is not supported by the MFW\n"); - rc = qed_mcp_resc_unlock(p_hwfn, p_ptt, - &resc_unlock_params); - if (rc) - DP_INFO(p_hwfn, - "Failed to release the resource lock for the resource allocation commands\n"); } + + DP_INFO(p_hwfn, + "Skip the max values setting of the soft resources since it is not supported by the MFW\n"); + rc = qed_mcp_resc_unlock(p_hwfn, p_ptt, + &resc_unlock_params); + if (rc) + DP_INFO(p_hwfn, + "Failed to release the resource lock for the resource allocation commands\n"); } rc = qed_hw_set_resc_info(p_hwfn);