From patchwork Fri Oct 22 03:37: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: 12576975 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 53D46C433EF for ; Fri, 22 Oct 2021 03:38:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2B6AD6103E for ; Fri, 22 Oct 2021 03:38:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232713AbhJVDka (ORCPT ); Thu, 21 Oct 2021 23:40:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230425AbhJVDk3 (ORCPT ); Thu, 21 Oct 2021 23:40:29 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A917C061766 for ; Thu, 21 Oct 2021 20:38:12 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id n11so1804073plf.4 for ; Thu, 21 Oct 2021 20:38:12 -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=Of3YKnTRn3u5CzD9gCv9m7aLwU5JnT9H9fbc3LybAE4=; b=PkqabWrTHhq+7m6FJ5Ng8hLr95mK27cSPVz+yxXKrJHPcCzZW3CKdtI4VdYNhLMSEw A3vtil+Lz7lsTAaynEIi8nl84D2ymC335wjjK8hbPbAbp7nhJhE0dUk825o7hMVeAjAV pildVo5fDPwHO4Vgrx2RjrertX6aVp4YbRNvqraDpDfaA4hlHLqalhksQHYI8mPNoWEI Pz+di38M4TeckMg2Mqa4YP3Wi63ERGsi/Sep2I16UH/RFqhRqvCXvdzvO1iu8DInoD72 i+G5pq2lp+YtMV9ikCoX97BTsZW2fGgy2pxxgPF8sasG4QdRvjbYIkbLS5Z7JsWSclWZ +Uqw== 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=Of3YKnTRn3u5CzD9gCv9m7aLwU5JnT9H9fbc3LybAE4=; b=ZFe3wPpYe46h555qvDhCoqDKReiXpaPvE1U1ox0MtgjsUgLx+X6lgI0GIwfEvY+Pai F4tTgg0G2rYIPOeLBdjnF9XoenPhT6SHkfwx3j62F4mKumRWOxY5mRmAdseugJhS0yT0 80IBWLRXR3CEG0Co332ZQuFigUlOBtDQTOVveVF2YZi8+rgANDe1MDOwC8bJ+DDA+pXI GYmMDJ8NL+2BT0lcFqht9cdzQ+otSyFJNZrdJuhfp0PFg36iLlq8yxTT96lb3FBykTJ6 tO/cgpZ/NQPtqNP3k+BPJ/15/913MGYLzEbjmgxZFLc6n73MTl5LoqCoIvoL5CqKcimG 7XEA== X-Gm-Message-State: AOAM5318JPaPog7Ina7dq366Zuef/bUEWy8k9bfxAiPhvKd4dqHs8MAS FuLmtiwsUkJ85PrP/nSpehU= X-Google-Smtp-Source: ABdhPJykuDKVo2+mz++PRu4qjMpynCW98JUkR3TP93e0PRBF0lxaUhEc/7IrkXfTq2Z3QC2UGXF/Og== X-Received: by 2002:a17:90b:3a85:: with SMTP id om5mr11627761pjb.115.1634873892063; Thu, 21 Oct 2021 20:38:12 -0700 (PDT) Received: from localhost ([23.129.64.158]) by smtp.gmail.com with ESMTPSA id n14sm6573703pgd.68.2021.10.21.20.38.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 20:38:11 -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 v2 1/2] net: qed_ptp: fix redundant check of rc and against -EINVAL Date: Thu, 21 Oct 2021 21:37:42 -0600 Message-Id: <927234fe6f6d9d50b9803e57bb370f97342ae2f0.1634847661.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. 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 Reviewed-by: Simon Horman Acked-by: Prabhakar Kushwaha --- 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(-) 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 Fri Oct 22 03:37: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: 12576973 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 AD3A6C433F5 for ; Fri, 22 Oct 2021 03:38:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 864C5614C8 for ; Fri, 22 Oct 2021 03:38:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232774AbhJVDkU (ORCPT ); Thu, 21 Oct 2021 23:40:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232769AbhJVDkT (ORCPT ); Thu, 21 Oct 2021 23:40:19 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC890C061766 for ; Thu, 21 Oct 2021 20:38:02 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id g5so1819539plg.1 for ; Thu, 21 Oct 2021 20:38:02 -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=XFHyBWIo8Rmp9KJl/2Jpr5MB6MTwQ9dvAVnHETi6YR8=; b=YA9ArQQ80eIhITwATJ4Y1wc9Ip4yhMnZ2IsDcpRMAuXKmy93uWijrnrBNIrx/7v16e INnAv0lIgcVGgD39Ujiahb+Lj0DnIVHeiXhx0avH2Dd9HdOw8zPm3ZFWjsIEXgBFOyOP 1m/PsBHCNH/BMt3nPMQ4NftuYXLm4LqnjqxZxdoLuBqIW78Jy+2RsHY2HEHAZaaa8Wtu l/c3Sxgyjzk9hAMFHtQnIKq0uBUWbz6PICo9IdfAzAhQmBc8WnAn5gsCrcETDOCSGbbH p0fwZy3wFG1SBycyDHHnR+k5w4SHeDXWvoST817utFgQvC0eawVaCm29T17wWOOWh30/ zUIw== 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=XFHyBWIo8Rmp9KJl/2Jpr5MB6MTwQ9dvAVnHETi6YR8=; b=jA1+uwLLWQRV0yAxEHMyd1ypGcApk9wf9az9YUgB4Q/QywbVI2X/yaWdgLg63bqQ/0 8JbDylPrX98y/KraPfzB9PSUIDYo0wy23uemOL5ET9DrFT5c43+a1qCWepM+j555YNLA fOMTgAyG9woRVYjyWvP4NkoHWI1kcqmNPekQq3RjjoYUw2I7YR4Kg0+CRpo1GxzvwpNU yvXJPWKHaxwPBZlzsB9BUVIunDpUK/fSaV4lFxJfAAnI3Jg8LnknPG73foXB4lrLlp8/ yDxVOdcaRYsxXCJyev1U967ghXiggPHwa12/3D73xBHaYqBVRYX8FzNIe47IhHkjR6YU Os7A== X-Gm-Message-State: AOAM533aEuVX+gSNmietp2/wHdRh1l93oSpMaGswRljIX2bw4+JmYfkn /Wuk90QQvymi/tYEXvTriHwxOWHylKDdDA== X-Google-Smtp-Source: ABdhPJySGUQlTlQ9puq2uUXxih5E/8vxT2mLVD3OmsBkzt5bSEbVvUyy3BjUwXB8FYOkbOUHuxxxrA== X-Received: by 2002:a17:902:6b48:b0:13f:903c:bc2e with SMTP id g8-20020a1709026b4800b0013f903cbc2emr8943886plt.68.1634873882389; Thu, 21 Oct 2021 20:38:02 -0700 (PDT) Received: from localhost ([23.129.64.158]) by smtp.gmail.com with ESMTPSA id c9sm6536016pgq.58.2021.10.21.20.37.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 20:38:01 -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 v2 2/2] net: qed_dev: fix redundant check of rc and against -EINVAL Date: Thu, 21 Oct 2021 21:37:41 -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. We should also remove the check of !rc in this expression since it is always true: (!rc && !resc_lock_params.b_granted) Signed-off-by: Jean Sacren --- v2: (1) Fix missing else branch. I'm very sorry. (2) Add text for !rc removal in the changelog. (3) Put two lines of qed_mcp_resc_unlock() call into one. Thank you, Mr. Horman! drivers/net/ethernet/qlogic/qed/qed_dev.c | 31 +++++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c b/drivers/net/ethernet/qlogic/qed/qed_dev.c index 18f3bf7c4dfe..4ae9867b2535 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_dev.c +++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c @@ -3987,26 +3987,29 @@ 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) { - 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) { + if (!resc_lock_params.b_granted) { DP_NOTICE(p_hwfn, - "Failed to set the max values of the soft resources\n"); - goto unlock_and_exit; - } else if (rc == -EINVAL) { + "Failed to acquire the resource lock for the resource allocation commands\n"); + return -EBUSY; + } + + 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; + } + 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); + 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");