From patchwork Thu Nov 3 07:02:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak R Varma X-Patchwork-Id: 14691 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp362645wru; Thu, 3 Nov 2022 00:05:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4rtatbMMcJYp/2n3cCCEOk197O/Yaw5SG5PaANx/NmkAO7ynyRi5yyEh7QpBNpa7W8e4tP X-Received: by 2002:a05:6a00:218a:b0:56d:1bb6:af4f with SMTP id h10-20020a056a00218a00b0056d1bb6af4fmr26556646pfi.11.1667459135832; Thu, 03 Nov 2022 00:05:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667459135; cv=none; d=google.com; s=arc-20160816; b=IfDMPlliYjVneStfFjG+9MQU8df4elE8rmwWgKxJFrDuIzTEGMT/AJxsoPcdPgDjNd UTAt0d9J8mTpYn+FQTyLVxSm9uvh/6ksHe/Tv6OQZ+rCooMUzjVSylo/Fof8/6S26Uap p/01uYxeycQRj9P1yu604oeFg4XTS1BQqHOQlkvyeA14Jsg3wQC0BfdckgfBc2ag2GSp KVfUKt1Xr+9FIxO3sWdYH11dfPZvi2t2F3pUi04DgECI92ujxozNGeorJKvzvpL4vyr8 p4Ekfqs/gvLmm0NYazPz953Shcm0wuqDJUDMoxryUYf5khrTbKPffOuuHN0UGH2DofEq qt9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date:dkim-signature; bh=f6sV5CRnNipd2PBGo08vJJKQrFCp4r8f9ep5ALHm3JI=; b=bOwn//VArb88/qG+efWVTI9nMAoy98MYYlDFNkVf27yKXcmeVdn7pJIJKHBbJE1l4s Cwu75TPViHEyOj1GIQINH/zX+YY1CCe/L2a+Zah9P6MTxaBMYz09P3bwWpDbdyu7iJjZ 7sqc2/2r01JEXVs/lI4ZfWkKhYBOjtN+yK35gPFuQsIfS7dK5cFFYHOHbbFnfMcha1T5 a/SmewJmAhFAE7Jj7EcWatKJBcHXQ3f1cZJkV3BiOBmteLt6TkXTZZC7pZX6mQbKnNtp jxmFP0N6NopWBecWcRaZsquL0EZfAwoPAzW1OHCbDeG5ZuvScuDvSmD2D2Rr21iqRs3+ s80A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=NEb7IcCW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rj4-20020a17090b3e8400b00214201e8996si364254pjb.18.2022.11.03.00.05.22; Thu, 03 Nov 2022 00:05:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=NEb7IcCW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230165AbiKCHCi (ORCPT + 99 others); Thu, 3 Nov 2022 03:02:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230106AbiKCHCc (ORCPT ); Thu, 3 Nov 2022 03:02:32 -0400 Received: from msg-1.mailo.com (msg-1.mailo.com [213.182.54.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A518317436 for ; Thu, 3 Nov 2022 00:02:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1667458938; bh=LbwkXUJkhNlCZNV3zGGjX8aci4KU7P3XQszdxoLXxF4=; h=X-EA-Auth:Date:From:To:Subject:Message-ID:MIME-Version: Content-Type; b=NEb7IcCWROFjQN/qMdp4a6OisJXKve86BDL4yC2gcYL+snDeVZG2Ju6ISpWMyx19O 6+fe7LXmLvY7dSqgEeIEFx7TUlu0F4jfhTFGh+ackh5WdrYN6tmPm5I3Ale4t2AT5E YcB/8xczq7tw76PH3bPsKGVv613SKItEzYQvtFQ0= Received: by b-5.in.mailobj.net [192.168.90.15] with ESMTP via [213.182.55.206] Thu, 3 Nov 2022 08:02:18 +0100 (CET) X-EA-Auth: ccrmxYZEVx8BpUWbzEc8nx2bv9/66wZ3TA05DA56RNT+NYYXFgTHrxOhDfj2yqcH1vHQbnvb9+J6Wi5oVEz5RJO9dSzqcYqd Date: Thu, 3 Nov 2022 12:32:09 +0530 From: Deepak R Varma To: outreachy@lists.linux.dev, Greg Kroah-Hartman , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH] staging: rtl8723bs: Use min/max macros for variable comparison Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748457630566457680?= X-GMAIL-MSGID: =?utf-8?q?1748457630566457680?= Simplify code by using min and max helper macros in place of lengthy if/else block oriented logical evaluation and value assignment. This issue is identified by coccicheck using the minmax.cocci file. Signed-off-by: Deepak R Varma --- Please note: 1. Using min for max_AMPDU_len computation warning was NOT auto generated by the cocciecheck command. This was caught while surround code review and was manually changed. 2. Checkpatch script continues to complaint about min_MPDU_spacing computation line being more than 100 character in length. I did not find a better formatting that will address this checkpatch warning. Any suggestions are most welcome. 3. Proposed changes are compile tested only on my x86 based VM. drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 12 ++++-------- drivers/staging/rtl8723bs/hal/odm_DIG.c | 5 +---- 2 files changed, 5 insertions(+), 12 deletions(-) -- 2.34.1 diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index 18ba846c0b7b..dcda587b84bc 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -986,15 +986,11 @@ void HT_caps_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE) pmlmeinfo->HT_caps.u.HT_cap[i] &= (pIE->data[i]); } else { /* modify from fw by Thomas 2010/11/17 */ - if ((pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3) > (pIE->data[i] & 0x3)) - max_AMPDU_len = (pIE->data[i] & 0x3); - else - max_AMPDU_len = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3); + max_AMPDU_len = min((pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3), + (pIE->data[i] & 0x3)); - if ((pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) > (pIE->data[i] & 0x1c)) - min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c); - else - min_MPDU_spacing = (pIE->data[i] & 0x1c); + min_MPDU_spacing = max((pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c), + (pIE->data[i] & 0x1c)); pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para = max_AMPDU_len | min_MPDU_spacing; } diff --git a/drivers/staging/rtl8723bs/hal/odm_DIG.c b/drivers/staging/rtl8723bs/hal/odm_DIG.c index 07edf74ccfe5..97a51546463a 100644 --- a/drivers/staging/rtl8723bs/hal/odm_DIG.c +++ b/drivers/staging/rtl8723bs/hal/odm_DIG.c @@ -598,10 +598,7 @@ void odm_DIGbyRSSI_LPS(void *pDM_VOID) /* Lower bound checking */ /* RSSI Lower bound check */ - if ((pDM_Odm->RSSI_Min-10) > DM_DIG_MIN_NIC) - RSSI_Lower = pDM_Odm->RSSI_Min-10; - else - RSSI_Lower = DM_DIG_MIN_NIC; + RSSI_Lower = max(pDM_Odm->RSSI_Min - 10, DM_DIG_MIN_NIC); /* Upper and Lower Bound checking */ if (CurrentIGI > DM_DIG_MAX_NIC)