From patchwork Thu Nov 3 09:33:29 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: 14785 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp419789wru; Thu, 3 Nov 2022 02:42:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6drw3xlQXwzZV3kkDzwZ8w6kIG7FTeNEvwr+F3pHssUnCLHZI0xLdylIJSYUyqD9CzNrml X-Received: by 2002:a05:6402:14ca:b0:462:e375:a1f4 with SMTP id f10-20020a05640214ca00b00462e375a1f4mr29663126edx.344.1667468573340; Thu, 03 Nov 2022 02:42:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667468573; cv=none; d=google.com; s=arc-20160816; b=Q3M5x8o2Scw8oRWLMJWQP/G5JUcsSmcoXZmcbNN6detXPrbG38wsXjnMSJZ01FLi6A SbgP/2oi53NmItKjrjhgtvJkkEpGell1w8am1SOiUSXFoGIe8nFadIUErsUywizEnpVN W+uhMM3YNoKXOk3Z+XwPt1aQ6G3UR8fSCXXMfGwj9xu6De2xBlKqexlA0wETqrrR64X4 V0Cr4ajWE7w+z8VnbrWDiW3waUExQPzv4msnBNRi374+Be4zeD7ojulERFjw112m26Mz isYrDVia0fK+z569xxzHTsgrojWg2z0Pcunr6UOdvDzBKuIEKM6ue3W2+NnY7d7JWyFu LlzQ== 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=3/cjEZ+2o9INyimXi12ulkcBAJPNDkEetxOM7Jgs5go=; b=E679tCfKMv3fokD/qKSkiwfhSUhOKhZlwNGYOj6rCUhlTCZx3oKS7RlvS+6AIssuYH hTeyXsHggkhmVK+rWV+vvlzrRN2GxGJe5jlYH+oNsJcDNkT6/nWrx+qhBlrC2Xu4FEs3 His7qRR1wJ71KdCa5aI2sfufgVU8xEzwC17JM17biRIZFxSPhTylUryKH26J+Xl2aBs0 jSo3B7BDIQM0kK3EU5aiIW47fahRmaaoRpA3xUpxbMvM0oBebovJMFquyGZ+EgnGEYT6 IAd2IDdapV79nQ+n2U6N5cwtZTD6Y4/7E0DeaAljmVuwAo8MgpkeXux6knMbWNea/YsT 9PLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=P48xDqiY; 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 g20-20020a1709061c9400b00780a240cfd7si531469ejh.493.2022.11.03.02.42.29; Thu, 03 Nov 2022 02:42:53 -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=P48xDqiY; 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 S229655AbiKCJdr (ORCPT + 99 others); Thu, 3 Nov 2022 05:33:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbiKCJdp (ORCPT ); Thu, 3 Nov 2022 05:33:45 -0400 Received: from msg-1.mailo.com (msg-1.mailo.com [213.182.54.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9DF22AD4 for ; Thu, 3 Nov 2022 02:33:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1667468017; bh=u4ZMyCJTtwT9XM0J3JSr+5jhaUWlQ9C7oJqTqy8JPvU=; h=X-EA-Auth:Date:From:To:Subject:Message-ID:MIME-Version: Content-Type; b=P48xDqiYtixEd4xMotP9apBBx9fXFI+Q3FCAS+DxRKaF6v1+m8U1nw2J+TO8WbGJZ DyY7ASx9Vlk5OX29eAyRWaLefK4O0tTX7hf7H8cY6y0fW6aTKbxz5Xc5QpLz6XhEoH 2TP8bUaRlUYHQR+MBoW9bDdYd+/BR8lpopI4FPjU= Received: by b-5.in.mailobj.net [192.168.90.15] with ESMTP via [213.182.55.206] Thu, 3 Nov 2022 10:33:37 +0100 (CET) X-EA-Auth: hF2FJLaDPFT0hZmNHvh6y/Itb5Izeetu6Xp6eqBJ5RVBeGH4W2bLWnm02z/QsIonphbvwWNdqcVqTMIMy6QTHSVvpmEoNdsX Date: Thu, 3 Nov 2022 15:03:29 +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 v2] 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?1748467526705273462?= 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 --- Changes in v2: 1. Remove unnecessary parenthesis around the min/max macro arguments as suggested by julia.lawall@inria.fr Please note: 1. Using min for max_AMPDU_len computation warning was NOT auto generated by the coccicheck 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..ba39c8b1a9ae 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)