From patchwork Thu Nov 19 22:25:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Cabiddu, Giovanni" X-Patchwork-Id: 328538 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C808C388F9 for ; Thu, 19 Nov 2020 22:25:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA310208FE for ; Thu, 19 Nov 2020 22:25:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726466AbgKSWZb (ORCPT ); Thu, 19 Nov 2020 17:25:31 -0500 Received: from mga01.intel.com ([192.55.52.88]:26654 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726105AbgKSWZb (ORCPT ); Thu, 19 Nov 2020 17:25:31 -0500 IronPort-SDR: jPutyleZCuA5th77TLJg6X7KIpHlwXK2FCV2tBBgt/5ax56cwHGqIDSONaWzwxJVOpXb69pxZJ dn0BPXod3ptQ== X-IronPort-AV: E=McAfee;i="6000,8403,9810"; a="189471936" X-IronPort-AV: E=Sophos;i="5.78,354,1599548400"; d="scan'208";a="189471936" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Nov 2020 14:25:30 -0800 IronPort-SDR: LmGCMt4qb3T1rKgJrsrSNZCnA5fx/qTFRH3Cj7MTclQZhGYUFHIrB4xm40mL6xuQ8a2lvZIgPq LOOH4iwIZjkA== X-IronPort-AV: E=Sophos;i="5.78,354,1599548400"; d="scan'208";a="476988121" Received: from silpixa00400314.ir.intel.com (HELO silpixa00400314) ([10.237.222.51]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Nov 2020 14:25:28 -0800 Date: Thu, 19 Nov 2020 22:25:19 +0000 From: Giovanni Cabiddu To: Julia Lawall Cc: Herbert Xu , Wojciech Ziemba , qat-linux@intel.com, Denis Efremov , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, kbuild-all@lists.01.org Subject: [PATCH RESEND] crypto: qat - fix excluded_middle.cocci warnings Message-ID: <20201119222519.GA138362@silpixa00400314> References: <20201119195816.GA131726@silpixa00400314> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201119195816.GA131726@silpixa00400314> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Thu, Nov 19, 2020 at 07:58:16PM +0000, Giovanni Cabiddu wrote: > On Fri, Nov 13, 2020 at 06:14:00PM +0100, Julia Lawall wrote: > > From: kernel test robot > > > > Condition !A || A && B is equivalent to !A || B. > A similar change was submitted and discussed some time ago: > https://patchwork.kernel.org/project/linux-crypto/patch/78b1532c-f8bf-48e4-d0a7-30ea0137d408@huawei.com/ > > The change simplifies the logic but makes the code less readable. > I added a comment to clarify it. Resending as it skipped linux-crypto patchwork. ----8<---- From: kernel test robot Date: Fri, 13 Nov 2020 18:14:00 +0100 Subject: [PATCH] crypto: qat - fix excluded_middle.cocci warnings Condition !A || A && B is equivalent to !A || B. Generated by: scripts/coccinelle/misc/excluded_middle.cocci Fixes: b76f0ea01312 ("coccinelle: misc: add excluded_middle.cocci script") CC: Denis Efremov Reported-by: kernel test robot Signed-off-by: kernel test robot Signed-off-by: Julia Lawall Signed-off-by: Giovanni Cabiddu --- drivers/crypto/qat/qat_common/adf_dev_mgr.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/qat/qat_common/adf_dev_mgr.c b/drivers/crypto/qat/qat_common/adf_dev_mgr.c index 29dc2e3d38ff..4c752eed10fe 100644 --- a/drivers/crypto/qat/qat_common/adf_dev_mgr.c +++ b/drivers/crypto/qat/qat_common/adf_dev_mgr.c @@ -151,8 +151,8 @@ int adf_devmgr_add_dev(struct adf_accel_dev *accel_dev, mutex_lock(&table_lock); atomic_set(&accel_dev->ref_count, 0); - /* PF on host or VF on guest */ - if (!accel_dev->is_vf || (accel_dev->is_vf && !pf)) { + /* PF on host or VF on guest - optimized to remove redundant is_vf */ + if (!accel_dev->is_vf || !pf) { struct vf_id_map *map; list_for_each(itr, &accel_table) { @@ -248,7 +248,8 @@ void adf_devmgr_rm_dev(struct adf_accel_dev *accel_dev, struct adf_accel_dev *pf) { mutex_lock(&table_lock); - if (!accel_dev->is_vf || (accel_dev->is_vf && !pf)) { + /* PF on host or VF on guest - optimized to remove redundant is_vf */ + if (!accel_dev->is_vf || !pf) { id_map[accel_dev->accel_id] = 0; num_devices--; } else if (accel_dev->is_vf && pf) {