Message ID | Y2LxC2kziM1TznhO@qemulion |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp187298wru; Wed, 2 Nov 2022 15:52:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM76lbe1D2lfbFXzHMieNFKhCxg8dVzfPjri02Y1NVUpqkja7twxbEnh/XRKj+OQbumXZ/P6 X-Received: by 2002:a17:90a:7301:b0:213:8a08:2f18 with SMTP id m1-20020a17090a730100b002138a082f18mr28661477pjk.50.1667429552425; Wed, 02 Nov 2022 15:52:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667429552; cv=none; d=google.com; s=arc-20160816; b=NMLYxD9YK95+pBbs2ha40Ef6v5iCUvBtoS9xXniGsoRbSjuQddJETFJ+Oi7CthxDhY VRGAk7m63glymuxj/KRScbnX/NBkvBJCqQL57qH3bEuPUaso1Ri4Tg6KgTUHj6adMjBF qHqbR/cjUCidPIaJRDwp9/N6LwDJ9tiswo0AKMlIWnc92EChBdiliJY2EXDyc0iWPYUC CjatOua5MUHfNyc0R+0UZASzR4VsZQPt6shsvFfaKIivGk3t7kW3CpVde+J9P1/WOkix saLgu/jaH2rZLAvxuhM85skhqkCTKcbyNsCiCbGMFdg+jhmZYJxvHTkfxGNYConrSlvh aGlQ== 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=MwtcWZZ1t1lBXc7++k9TiSX211tpec0jJT1qpwrzh+M=; b=AzOPHOMwSihX/eafgQxpw+emh4eG7EPtQBIeGRTl34EM/z0U1vz2s3auOqFC+nBHSn 5eI47acyGj43lCgnKo9QOxsSUmfEp3K+v9S38CMxw9RniLMVgfFnRnL5A7CpqX0Is65c w4vdT/hmCcj9V6kuruUZqOfs1FudF9eBy1OQRm3R8hcA98K0tbyBZDaDO59yiVU8vDSA jCT4aZnfJcJylbG2T0uANXCXpp3P0rV35P5UKz75/KokoNBDhcgj8wWhzwUsju7aX+Hh JcFhmwtHStQJdiocRhkQlCTEIlvo+1FX8aXJUlP1eSbY9Do9Cqpm2Cjr8xrx6+kDz1zn yQdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=eLa3HMC9; 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 cv21-20020a17090afd1500b001fe1c9436b1si3257704pjb.86.2022.11.02.15.52.19; Wed, 02 Nov 2022 15:52:32 -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=eLa3HMC9; 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 S231526AbiKBWhP (ORCPT <rfc822;yves.mi.zy@gmail.com> + 99 others); Wed, 2 Nov 2022 18:37:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230196AbiKBWhO (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 2 Nov 2022 18:37:14 -0400 Received: from msg-1.mailo.com (msg-1.mailo.com [213.182.54.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9506BE25 for <linux-kernel@vger.kernel.org>; Wed, 2 Nov 2022 15:37:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1667428623; bh=Jh9hVKlG9E8M6+Hg4/uFDmdMr+5rCinh9+KF12rxCMs=; h=X-EA-Auth:Date:From:To:Subject:Message-ID:MIME-Version: Content-Type; b=eLa3HMC9o56WEYZq2SgqNyfJWWMf14vSK+J+8Kjo/Wz4Z9/jOClxEgzxzq4VSyik9 yQAZGFrNuIQTvtblfxcgbc1kj8dt97CffGv8a3yBmVKLuT0w7bkCxxwzmmq8g5oatW xhEm4Xgo1HYeDvNL3ZxA2G1vE2+ROoZueYOczGe0= Received: by b-5.in.mailobj.net [192.168.90.15] with ESMTP via [213.182.55.206] Wed, 2 Nov 2022 23:37:03 +0100 (CET) X-EA-Auth: w+3zi4nkHeGs1aO9AAZFE88t8u3GtxhuNPQ5I+2Kebsq2h73girS4qV9PZWmt8dwhm8SNoKbKQoIgCfn4kr4gD0xympHdQW7 Date: Thu, 3 Nov 2022 04:06:59 +0530 From: Deepak R Varma <drv@mailo.com> To: outreachy@lists.linux.dev, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH] staging: rtl8192e: Use min_t/max_t macros for variable comparison Message-ID: <Y2LxC2kziM1TznhO@qemulion> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748426610355967795?= X-GMAIL-MSGID: =?utf-8?q?1748426610355967795?= |
Series |
staging: rtl8192e: Use min_t/max_t macros for variable comparison
|
|
Commit Message
Deepak R Varma
Nov. 2, 2022, 10:36 p.m. UTC
Simplify code by using min_t and max_t 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.
Use the *_t variants of min/max macros to avoid compiler warnings about
data typecast.
Also, use u32 as type for min_t macro to avoid any truncation of data
associated with enum constant HT_AGG_SIZE_32K.
Signed-off-by: Deepak R Varma <drv@mailo.com>
---
drivers/staging/rtl8192e/rtl819x_HTProc.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
--
2.34.1
Comments
On 11/2/22 23:36, Deepak R Varma wrote: > Simplify code by using min_t and max_t 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. > > Use the *_t variants of min/max macros to avoid compiler warnings about > data typecast. > Also, use u32 as type for min_t macro to avoid any truncation of data > associated with enum constant HT_AGG_SIZE_32K. > > Signed-off-by: Deepak R Varma <drv@mailo.com> > --- > drivers/staging/rtl8192e/rtl819x_HTProc.c | 13 ++++--------- > 1 file changed, 4 insertions(+), 9 deletions(-) > > diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c > index 62aa8e893c34..ccb86660ab48 100644 > --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c > +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c > @@ -587,17 +587,12 @@ void HTOnAssocRsp(struct rtllib_device *ieee) > else > pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_64K; > } else { > - if (pPeerHTCap->MaxRxAMPDUFactor < HT_AGG_SIZE_32K) > - pHTInfo->CurrentAMPDUFactor = > - pPeerHTCap->MaxRxAMPDUFactor; > - else > - pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_32K; > + pHTInfo->CurrentAMPDUFactor = min_t(u32, pPeerHTCap->MaxRxAMPDUFactor, > + HT_AGG_SIZE_32K); > } > } > - if (pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity) > - pHTInfo->current_mpdu_density = pHTInfo->MPDU_Density; > - else > - pHTInfo->current_mpdu_density = pPeerHTCap->MPDUDensity; > + pHTInfo->current_mpdu_density = max_t(u8, pHTInfo->MPDU_Density, > + pPeerHTCap->MPDUDensity); > if (pHTInfo->iot_action & HT_IOT_ACT_TX_USE_AMSDU_8K) { > pHTInfo->bCurrentAMPDUEnable = false; > pHTInfo->ForcedAMSDUMode = HT_AGG_FORCE_ENABLE; > -- > 2.34.1 > > > > Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>
From: Deepak R Varma > Sent: 02 November 2022 22:37 > > Simplify code by using min_t and max_t 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. > > Use the *_t variants of min/max macros to avoid compiler warnings about > data typecast. > Also, use u32 as type for min_t macro to avoid any truncation of data > associated with enum constant HT_AGG_SIZE_32K. > > Signed-off-by: Deepak R Varma <drv@mailo.com> > --- > drivers/staging/rtl8192e/rtl819x_HTProc.c | 13 ++++--------- > 1 file changed, 4 insertions(+), 9 deletions(-) > > diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c > index 62aa8e893c34..ccb86660ab48 100644 > --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c > +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c > @@ -587,17 +587,12 @@ void HTOnAssocRsp(struct rtllib_device *ieee) > else > pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_64K; > } else { > - if (pPeerHTCap->MaxRxAMPDUFactor < HT_AGG_SIZE_32K) > - pHTInfo->CurrentAMPDUFactor = > - pPeerHTCap->MaxRxAMPDUFactor; > - else > - pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_32K; > + pHTInfo->CurrentAMPDUFactor = min_t(u32, pPeerHTCap->MaxRxAMPDUFactor, > + HT_AGG_SIZE_32K); For min() to fail there must be a signed v unsigned mismatch. Maybe that ought to be fixed. > } > } > - if (pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity) > - pHTInfo->current_mpdu_density = pHTInfo->MPDU_Density; > - else > - pHTInfo->current_mpdu_density = pPeerHTCap->MPDUDensity; > + pHTInfo->current_mpdu_density = max_t(u8, pHTInfo->MPDU_Density, > + pPeerHTCap->MPDUDensity); Using u8 with max_t() really doesn't make any sense. The value will get promoted to signed int prior to the comparison. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
On Thu, Nov 03, 2022 at 08:24:15AM +0000, David Laight wrote: > > --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c > > +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c > > @@ -587,17 +587,12 @@ void HTOnAssocRsp(struct rtllib_device *ieee) > > else > > pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_64K; > > } else { > > - if (pPeerHTCap->MaxRxAMPDUFactor < HT_AGG_SIZE_32K) > > - pHTInfo->CurrentAMPDUFactor = > > - pPeerHTCap->MaxRxAMPDUFactor; > > - else > > - pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_32K; > > + pHTInfo->CurrentAMPDUFactor = min_t(u32, pPeerHTCap->MaxRxAMPDUFactor, > > + HT_AGG_SIZE_32K); > > For min() to fail there must be a signed v unsigned mismatch. > Maybe that ought to be fixed. > u32 is the right choice here. I'm having a hard time understanding your email. You might be saying we could declare HT_AGG_SIZE_32K as a u32 so then we could use min() instead of min_t()? HT_AGG_SIZE_32K is an enum. pPeerHTCap->MaxRxAMPDUFactor is a bitfield. u8 MaxRxAMPDUFactor:2; We will never be able to use min(). > > } > > } > > - if (pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity) > > - pHTInfo->current_mpdu_density = pHTInfo->MPDU_Density; > > - else > > - pHTInfo->current_mpdu_density = pPeerHTCap->MPDUDensity; > > + pHTInfo->current_mpdu_density = max_t(u8, pHTInfo->MPDU_Density, > > + pPeerHTCap->MPDUDensity); > > Using u8 with max_t() really doesn't make any sense. Using u8 looks wrong because you would worry that one of the types is larger than U8_MAX. But it's actually fine. The types are u8 vs another bitfield. I would probably have gone with u32 here as well. > The value will get promoted to signed int prior to the comparison. > That's sort of true-ish but I don't understand what you are saying? #confused regards, dan carpenter
On Thu, Nov 03, 2022 at 11:53:45AM +0300, Dan Carpenter wrote: > On Thu, Nov 03, 2022 at 08:24:15AM +0000, David Laight wrote: > > > --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c > > > +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c > > > @@ -587,17 +587,12 @@ void HTOnAssocRsp(struct rtllib_device *ieee) > > > else > > > pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_64K; > > > } else { > > > - if (pPeerHTCap->MaxRxAMPDUFactor < HT_AGG_SIZE_32K) > > > - pHTInfo->CurrentAMPDUFactor = > > > - pPeerHTCap->MaxRxAMPDUFactor; > > > - else > > > - pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_32K; > > > + pHTInfo->CurrentAMPDUFactor = min_t(u32, pPeerHTCap->MaxRxAMPDUFactor, > > > + HT_AGG_SIZE_32K); > > > > For min() to fail there must be a signed v unsigned mismatch. > > Maybe that ought to be fixed. > > > > u32 is the right choice here. > > I'm having a hard time understanding your email. You might be saying > we could declare HT_AGG_SIZE_32K as a u32 so then we could use min() > instead of min_t()? HT_AGG_SIZE_32K is an enum. > > pPeerHTCap->MaxRxAMPDUFactor is a bitfield. > > u8 MaxRxAMPDUFactor:2; > > We will never be able to use min(). I think we could do min((u32)a, (u32)b), but it is just unwrapped min_t if I understand David's comment. > > > > } > > > } > > > - if (pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity) > > > - pHTInfo->current_mpdu_density = pHTInfo->MPDU_Density; > > > - else > > > - pHTInfo->current_mpdu_density = pPeerHTCap->MPDUDensity; > > > + pHTInfo->current_mpdu_density = max_t(u8, pHTInfo->MPDU_Density, > > > + pPeerHTCap->MPDUDensity); > > > > Using u8 with max_t() really doesn't make any sense. > > Using u8 looks wrong because you would worry that one of the types is > larger than U8_MAX. But it's actually fine. The types are u8 vs another > bitfield. I would probably have gone with u32 here as well. I will take your advise and upgrade the type to u32 as a revision. > > > The value will get promoted to signed int prior to the comparison. > > > > That's sort of true-ish but I don't understand what you are saying? > #confused Yes, I too did not understand David's comment. I tried to dig dipper into max_t but it gets very complex. Can you please elaborate how you determined the promotion to signed int? > > regards, > dan carpenter > >
On Thu, Nov 03, 2022 at 02:48:35PM +0530, Deepak R Varma wrote: > On Thu, Nov 03, 2022 at 11:53:45AM +0300, Dan Carpenter wrote: > > On Thu, Nov 03, 2022 at 08:24:15AM +0000, David Laight wrote: > > > > --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c > > > > +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c > > > > @@ -587,17 +587,12 @@ void HTOnAssocRsp(struct rtllib_device *ieee) > > > > else > > > > pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_64K; > > > > } else { > > > > - if (pPeerHTCap->MaxRxAMPDUFactor < HT_AGG_SIZE_32K) > > > > - pHTInfo->CurrentAMPDUFactor = > > > > - pPeerHTCap->MaxRxAMPDUFactor; > > > > - else > > > > - pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_32K; > > > > + pHTInfo->CurrentAMPDUFactor = min_t(u32, pPeerHTCap->MaxRxAMPDUFactor, > > > > + HT_AGG_SIZE_32K); > > > > > > For min() to fail there must be a signed v unsigned mismatch. > > > Maybe that ought to be fixed. > > > > > > > u32 is the right choice here. > > > > I'm having a hard time understanding your email. You might be saying > > we could declare HT_AGG_SIZE_32K as a u32 so then we could use min() > > instead of min_t()? HT_AGG_SIZE_32K is an enum. > > > > pPeerHTCap->MaxRxAMPDUFactor is a bitfield. > > > > u8 MaxRxAMPDUFactor:2; > > > > We will never be able to use min(). > > I think we could do min((u32)a, (u32)b), but it is just unwrapped min_t > if I understand David's comment. > No. Do not do that. I think it's a checkpatch warning. What you have is fine. > > > > > > } > > > > } > > > > - if (pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity) > > > > - pHTInfo->current_mpdu_density = pHTInfo->MPDU_Density; > > > > - else > > > > - pHTInfo->current_mpdu_density = pPeerHTCap->MPDUDensity; > > > > + pHTInfo->current_mpdu_density = max_t(u8, pHTInfo->MPDU_Density, > > > > + pPeerHTCap->MPDUDensity); > > > > > > Using u8 with max_t() really doesn't make any sense. > > > > Using u8 looks wrong because you would worry that one of the types is > > larger than U8_MAX. But it's actually fine. The types are u8 vs another > > bitfield. I would probably have gone with u32 here as well. > I will take your advise and upgrade the type to u32 as a revision. Sounds good. It's not something I would have asked you to redo the patch over, but it would have been my personal preference. regards, dan carpenter
On Thu, Nov 03, 2022 at 01:09:20PM +0300, Dan Carpenter wrote: > On Thu, Nov 03, 2022 at 02:48:35PM +0530, Deepak R Varma wrote: > > On Thu, Nov 03, 2022 at 11:53:45AM +0300, Dan Carpenter wrote: > > > On Thu, Nov 03, 2022 at 08:24:15AM +0000, David Laight wrote: > > > > > --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c > > > > > +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c > > > > > @@ -587,17 +587,12 @@ void HTOnAssocRsp(struct rtllib_device *ieee) > > > > > else > > > > > pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_64K; > > > > > } else { > > > > > - if (pPeerHTCap->MaxRxAMPDUFactor < HT_AGG_SIZE_32K) > > > > > - pHTInfo->CurrentAMPDUFactor = > > > > > - pPeerHTCap->MaxRxAMPDUFactor; > > > > > - else > > > > > - pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_32K; > > > > > + pHTInfo->CurrentAMPDUFactor = min_t(u32, pPeerHTCap->MaxRxAMPDUFactor, > > > > > + HT_AGG_SIZE_32K); > > > > > > > > For min() to fail there must be a signed v unsigned mismatch. > > > > Maybe that ought to be fixed. > > > > > > > > > > u32 is the right choice here. > > > > > > I'm having a hard time understanding your email. You might be saying > > > we could declare HT_AGG_SIZE_32K as a u32 so then we could use min() > > > instead of min_t()? HT_AGG_SIZE_32K is an enum. > > > > > > pPeerHTCap->MaxRxAMPDUFactor is a bitfield. > > > > > > u8 MaxRxAMPDUFactor:2; > > > > > > We will never be able to use min(). > > > > I think we could do min((u32)a, (u32)b), but it is just unwrapped min_t > > if I understand David's comment. > > > > No. Do not do that. I think it's a checkpatch warning. What you have > is fine. > > > > > > > > > } > > > > > } > > > > > - if (pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity) > > > > > - pHTInfo->current_mpdu_density = pHTInfo->MPDU_Density; > > > > > - else > > > > > - pHTInfo->current_mpdu_density = pPeerHTCap->MPDUDensity; > > > > > + pHTInfo->current_mpdu_density = max_t(u8, pHTInfo->MPDU_Density, > > > > > + pPeerHTCap->MPDUDensity); > > > > > > > > Using u8 with max_t() really doesn't make any sense. > > > > > > Using u8 looks wrong because you would worry that one of the types is > > > larger than U8_MAX. But it's actually fine. The types are u8 vs another > > > bitfield. I would probably have gone with u32 here as well. > > I will take your advise and upgrade the type to u32 as a revision. > > Sounds good. It's not something I would have asked you to redo the > patch over, but it would have been my personal preference. That is no problem. I am waiting on David to elaborate on his feedback and accordingly plan a consolidated revision. > > regards, > dan carpenter > >
diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index 62aa8e893c34..ccb86660ab48 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -587,17 +587,12 @@ void HTOnAssocRsp(struct rtllib_device *ieee) else pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_64K; } else { - if (pPeerHTCap->MaxRxAMPDUFactor < HT_AGG_SIZE_32K) - pHTInfo->CurrentAMPDUFactor = - pPeerHTCap->MaxRxAMPDUFactor; - else - pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_32K; + pHTInfo->CurrentAMPDUFactor = min_t(u32, pPeerHTCap->MaxRxAMPDUFactor, + HT_AGG_SIZE_32K); } } - if (pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity) - pHTInfo->current_mpdu_density = pHTInfo->MPDU_Density; - else - pHTInfo->current_mpdu_density = pPeerHTCap->MPDUDensity; + pHTInfo->current_mpdu_density = max_t(u8, pHTInfo->MPDU_Density, + pPeerHTCap->MPDUDensity); if (pHTInfo->iot_action & HT_IOT_ACT_TX_USE_AMSDU_8K) { pHTInfo->bCurrentAMPDUEnable = false; pHTInfo->ForcedAMSDUMode = HT_AGG_FORCE_ENABLE;