From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755377AbdEDQJE (ORCPT ); Thu, 4 May 2017 12:09:04 -0400 Received: from smtprelay0205.hostedemail.com ([216.40.44.205]:49204 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755201AbdEDQJC (ORCPT ); Thu, 4 May 2017 12:09:02 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::,RULES_HIT:41:355:379:541:599:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3870:3871:3872:4321:4605:5007:7903:8660:10004:10400:10848:11026:11232:11473:11658:11914:12043:12296:12740:12760:12895:13069:13148:13230:13311:13357:13439:14096:14097:14181:14659:14721:21080:21451:21627:30012:30054:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:8,LUA_SUMMARY:none X-HE-Tag: vein00_136187edd4409 X-Filterd-Recvd-Size: 2765 Message-ID: <1493914131.22125.35.camel@perches.com> Subject: Re: [PATCH] vt6656: Coding style fixes From: Joe Perches To: Simo Koskinen , forest@alittletooquiet.net Cc: gregkh@linuxfoundation.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Date: Thu, 04 May 2017 09:08:51 -0700 In-Reply-To: <1493912028-2721-1-git-send-email-koskisoft@gmail.com> References: <1493912028-2721-1-git-send-email-koskisoft@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.6-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2017-05-04 at 17:33 +0200, Simo Koskinen wrote: > Fixed coding style warnings reported by checkpatch.pl. Please strive to do more than shut up checkpatch. Think a little about what this code is doing. Spend the time to analyze the code and improve it. For instance, this function is currently: static u32 vnt_get_rsvtime(struct vnt_private *priv, u8 pkt_type, u32 frame_length, u16 rate, int need_ack) { u32 data_time, ack_time; data_time = vnt_get_frame_time(priv->preamble_type, pkt_type, frame_length, rate); if (pkt_type == PK_TYPE_11B) ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type, 14, (u16)priv->top_cck_basic_rate); else ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type, 14, (u16)priv->top_ofdm_basic_rate); if (need_ack) return data_time + priv->sifs + ack_time; return data_time; } It is computing how long it takes to do something. It also is doing the ack_time calculation unnecessarily when need_ack is not set. Better code might be something like: static u32 vnt_get_rsvtime(struct vnt_private *priv, u8 pkt_type, u32 frame_length, u16 rate, int need_ack) { u32 data_time, ack_time; data_time = vnt_get_frame_time(priv->preamble_type, pkt_type, frame_length, rate); if (!need_ack) return data_time; if (pkt_type == PK_TYPE_11B) rate = priv->top_cck_basic_rate; else rate = priv->top_ofdm_basic_rate; ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type, 14, rate); return data_time + priv->sifs + ack_time; } where the return of data_time is done when !need_ack and rate is calculated and a single vnt_get_frame_time call is used for ack_time only when necessary. It's slightly smaller object code and faster to execute when need_ack is not set. Ideally the hard-coded 14 value in the ack_time calculation should be a #define or a sizeof.