Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp244069pxj; Fri, 14 May 2021 02:18:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyw86qH5HuhnGv0Rs9KNDWSSUH17oXpPOtChfqwjdEYLwzeVbRNEwUlwICRCS+g+NUGupzx X-Received: by 2002:a05:6602:2acc:: with SMTP id m12mr17179959iov.58.1620983896110; Fri, 14 May 2021 02:18:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620983896; cv=none; d=google.com; s=arc-20160816; b=O3qD4HZrfNUKCfWjiR49x/a8TXjDyFg3ABjzFVuuDFTfTyl7ckGQWtVi+tHgcTm+kR HxzOzH8x8PjMlmqt7lM7zEd5/UcKuwySDdF6sxwtgnZl/Rl4hnlxtIpT9s0bTQ6hdiCl +QwYI7hwz7BQtNNzC3r/wSt8na+kQ0A74i6gra3dN4BCLysG7gyHn4OB2uOn53D+3FNs L72MslyU0cU+6mN/+XmneLFpus6PoXCnyYP32FhHw4Jd0Y1+AHBR6CWi6zf0Fh1GOkSj Ty0a4Qufpqgol/uVxiNN7UtifjU0qyX82vHi/FvLWnUnoDqRt4SLxxKSqOwlW5Eb59Rc NvcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=TIp0TUO+tNBFklQ/2WorP40sHVp/VQIergbfAFVxz6g=; b=j99vIsGK8g1XpQvyxXBnHN9A1mZOgLgOpq6d8aQSCWOMPqkkvYPtDeJzgi5FRf2L8y Llf3IKChtcAq+Nr7aE4heBMgO7k8JiCcGPQGcFGusK7z1SjgFhR5PlIEguNjSzPYF33s TlWFvpXolwGAB/U13vgzZVWVgkN8w4Vr0wyhAmJw2VinnoHmVxVmnQtne8Houg9vW9wY zkKoUagQHLagqKG+f5dVFogk5lQnMD9yq/Fj9VV+oQWJ8/IpWccRlZ9MNoVE7jbTH8bt GnTyne9E353dIzfdw8kXXNIx4auiNXCVHSier5X2W21Y0r0nbaBq3Jnz4VOf62lTNFEd fNww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b5si7078597ioh.5.2021.05.14.02.18.03; Fri, 14 May 2021 02:18:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232182AbhENEX1 (ORCPT + 99 others); Fri, 14 May 2021 00:23:27 -0400 Received: from smtprelay0235.hostedemail.com ([216.40.44.235]:52356 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232177AbhENEX0 (ORCPT ); Fri, 14 May 2021 00:23:26 -0400 Received: from omf05.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay03.hostedemail.com (Postfix) with ESMTP id 10349837F24A; Fri, 14 May 2021 04:22:13 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf05.hostedemail.com (Postfix) with ESMTPA id 6D592B2796; Fri, 14 May 2021 04:22:10 +0000 (UTC) Message-ID: Subject: Re: [PATCH 2/7] rtl8xxxu: add handle for mac80211 get_txpower From: Joe Perches To: Reto Schneider , Jes.Sorensen@gmail.com, linux-wireless@vger.kernel.org, pkshih@realtek.com Cc: yhchuang@realtek.com, Larry.Finger@lwfinger.net, tehuang@realtek.com, reto.schneider@husqvarnagroup.com, ccchiu77@gmail.com, kvalo@codeaurora.org, davem@davemloft.net, kuba@kernel.org, Chris Chiu , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Date: Thu, 13 May 2021 21:22:09 -0700 In-Reply-To: <20210514020442.946-3-code@reto-schneider.ch> References: <20210514020442.946-1-code@reto-schneider.ch> <20210514020442.946-3-code@reto-schneider.ch> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.38.1-1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=1.56 X-Stat-Signature: dk8dqn4byhkc677ruoy5f8jfh8rn1dfe X-Rspamd-Server: rspamout04 X-Rspamd-Queue-Id: 6D592B2796 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX18ODrWJ8BvWBzNaBhnO6Y0bbB7RSrNHloA= X-HE-Tag: 1620966130-521492 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Fri, 2021-05-14 at 04:04 +0200, Reto Schneider wrote: > From: Chris Chiu > > add .get_txpower handle for mac80211 operations for `iw` and `wext` > tools to get the underlying tx power (max limit). [] > diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c [] > +int > +rtl8xxxu_gen1_get_tx_power(struct rtl8xxxu_priv *priv) > +{ > + u8 txpwr_level; > + int txpwr_dbm; > + > + txpwr_level = priv->cur_cck_txpwridx; > + txpwr_dbm = rtl8xxxu_gen1_txpwridx_to_dbm(priv, WIRELESS_MODE_B, > + txpwr_level); > + txpwr_level = priv->cur_ofdm24g_txpwridx + > + priv->ofdm_tx_power_index_diff[1].a; > + > + if (rtl8xxxu_gen1_txpwridx_to_dbm(priv, WIRELESS_MODE_G, txpwr_level) > + > txpwr_dbm) > + txpwr_dbm = rtl8xxxu_gen1_txpwridx_to_dbm(priv, WIRELESS_MODE_G, > + txpwr_level); probably better to use a temporaries instead of multiple calls. foo = rtl8xxxu_gen1_txpwridx_to_dbm(priv, WIRELESS_MODE_G, txpwr_level); if (foo > txpwr_dbm) txpwr_dbm = foo; > + txpwr_level = priv->cur_ofdm24g_txpwridx; > + if (rtl8xxxu_gen1_txpwridx_to_dbm(priv, WIRELESS_MODE_N_24G, > + txpwr_level) > txpwr_dbm) > + txpwr_dbm = rtl8xxxu_gen1_txpwridx_to_dbm(priv, > + WIRELESS_MODE_N_24G, > + txpwr_level); > + > + return txpwr_dbm; foo = rtl8xxxu_gen1_txpwridx_to_dbm(priv, WIRELESS_MODE_N_24G, txpwr_level); return min(txpwr_dbm, foo);