Re: [PATCH] Fix line too long warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Oct 29, 2017 at 06:54:09PM +0300, Yury Norov wrote:
> Hi Kien,
> 
> On Sat, Oct 28, 2017 at 10:46:13PM -0400, Kien Ha wrote:
> > >From fc52a98aca0c033f2c03fdc7e8f83ae49625675a Mon Sep 17 00:00:00 2001
> > From: Kien Ha <kienha9922@xxxxxxxxx>
> > Date: Fri, 27 Oct 2017 14:07:55 -0400
> > Subject: [PATCH] Fix line too long warning
> > 
> > Signed-off-by: Kien Ha <kienha9922@xxxxxxxxx>
> > ---
> >  drivers/staging/rtlwifi/base.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/staging/rtlwifi/base.c b/drivers/staging/rtlwifi/base.c
> > index b88b0e8edd3d..bbc80f976e12 100644
> > --- a/drivers/staging/rtlwifi/base.c
> > +++ b/drivers/staging/rtlwifi/base.c
> > @@ -1283,7 +1283,8 @@ void rtl_get_tcb_desc(struct ieee80211_hw *hw,
> >  				} else {
> >  					if (rtlmac->mode == WIRELESS_MODE_B) {
> >  						tcb_desc->hw_rate =
> > -						    rtlpriv->cfg->maps[RTL_RC_CCK_RATE11M];
> > +						    rtlpriv->cfg->maps[
> > +						    RTL_RC_CCK_RATE11M];
> 
> At first, if you fix this, you should also fix similar problem 3 lines
> below, right?
> 
> >  					} else {
> >  						tcb_desc->hw_rate =
> >  						    rtlpriv->cfg->maps[RTL_RC_OFDM_RATE54M];
> 
> At second, and most important, refer Documentation/process/coding-style.rst:
> Now, some people will claim that having 8-character indentations makes
> the code move too far to the right, and makes it hard to read on a 
> 80-character terminal screen.  The answer to that is that if you need 
> more than 3 levels of indentation, you're screwed anyway, and should fix
> your program.
> 
> The real problem here is not "line too long", but "indentation level too
> big" - 5. And it worth to address real problem.

It's not so hard though, something like this:

void rtl_get_tcb_desc(struct ieee80211_hw *hw,
		      struct ieee80211_tx_info *info,
		      struct ieee80211_sta *sta,
		      struct sk_buff *skb, struct rtl_tcb_desc *tcb_desc)
{
#define SET_RATE_ID(rate_id)					\
	((rtlpriv->cfg->spec_ver & RTL_SPEC_NEW_RATEID) ?	\
		rtl_mrate_idx_to_arfr_id(hw, rate_id,		\
			(sta_entry ? sta_entry->wireless_mode :	\
			 WIRELESS_MODE_G)) :			\
		rate_id)

	struct rtl_priv *rtlpriv = rtl_priv(hw);
	struct rtl_mac *rtlmac = rtl_mac(rtl_priv(hw));
	struct ieee80211_hdr *hdr = rtl_get_hdr(skb);
	struct rtl_sta_info *sta_entry =
		(sta ? (struct rtl_sta_info *)sta->drv_priv : NULL);

	__le16 fc = rtl_get_fc(skb);

	tcb_desc->hw_rate = _rtl_get_tx_hw_rate(hw, info);

	if (rtl_is_tx_report_skb(hw, skb))
		tcb_desc->use_spe_rpt = 1;

	if (!ieee80211_is_data(fc)) {
		tcb_desc->use_driver_rate = true;
		tcb_desc->ratr_index = SET_RATE_ID(RATR_INX_WIRELESS_MC);
		tcb_desc->disable_ratefallback = 1;
		tcb_desc->mac_id = 0;
		tcb_desc->packet_bw = false;
		return;
	}

	if (is_multicast_ether_addr(hdr->addr1))
		tcb_desc->multicast = 1;
	else if (is_broadcast_ether_addr(hdr->addr1))
		tcb_desc->broadcast = 1;

	/*
	 * we set data rate INX 0 in rtl_rc.c if skb is special data or
	 * mgt which need low data rate. So tcb_desc->hw_rate is just used
	 * for special data and mgt frames
	 */
	if (info->control.rates[0].idx == 0 || ieee80211_is_nullfunc(fc)) {
		tcb_desc->use_driver_rate = true;
		tcb_desc->ratr_index = SET_RATE_ID(RATR_INX_WIRELESS_MC);
		tcb_desc->disable_ratefallback = 1;
		goto rtl_query;
	}

	/* because hw will never use hw_rate
	 * when tcb_desc->use_driver_rate = false
	 * so we never set highest N rate here,
	 * and N rate will all be controlled by FW
	 * when tcb_desc->use_driver_rate = false
	 */
	if (sta && sta->vht_cap.vht_supported) {
		tcb_desc->hw_rate = _rtl_get_vht_highest_n_rate(hw, sta);
		goto rtl_query;
	}

	if (sta && (sta->ht_cap.ht_supported)) {
		tcb_desc->hw_rate = _rtl_get_highest_n_rate(hw, sta);
		goto rtl_query;
	}

	if (rtlmac->mode == WIRELESS_MODE_B)
		tcb_desc->hw_rate = rtlpriv->cfg->maps[RTL_RC_CCK_RATE11M];
	else
		tcb_desc->hw_rate = rtlpriv->cfg->maps[RTL_RC_OFDM_RATE54M];
rtl_query:
	_rtl_txrate_selectmode(hw, sta, tcb_desc);
	_rtl_query_bandwidth_mode(hw, sta, tcb_desc);
	_rtl_qurey_shortpreamble_mode(hw, tcb_desc, info);
	_rtl_query_shortgi(hw, sta, tcb_desc, info);
	_rtl_query_protection_mode(hw, tcb_desc, info);
#undef SET_RATE_ID
}

(Compeletely untested and most probably wrong, just illustration.)

Yury
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux