From nobody Thu Apr 9 06:20:17 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A54CEC433FE for ; Thu, 3 Nov 2022 09:33:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229770AbiKCJdr (ORCPT ); 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 generate= d 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 f= ind 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(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/stagi= ng/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] &=3D (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 =3D (pIE->data[i] & 0x3); - else - max_AMPDU_len =3D (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x= 3); + max_AMPDU_len =3D 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->dat= a[i] & 0x1c)) - min_MPDU_spacing =3D (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para &= 0x1c); - else - min_MPDU_spacing =3D (pIE->data[i] & 0x1c); + min_MPDU_spacing =3D max(pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para= & 0x1c, + pIE->data[i] & 0x1c); pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para =3D max_AMPDU_len | min_= MPDU_spacing; } diff --git a/drivers/staging/rtl8723bs/hal/odm_DIG.c b/drivers/staging/rtl8= 723bs/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 =3D pDM_Odm->RSSI_Min-10; - else - RSSI_Lower =3D DM_DIG_MIN_NIC; + RSSI_Lower =3D max(pDM_Odm->RSSI_Min - 10, DM_DIG_MIN_NIC); /* Upper and Lower Bound checking */ if (CurrentIGI > DM_DIG_MAX_NIC) -- 2.34.1