public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vt6656: Coding style fixes
@ 2017-05-04 15:33 Simo Koskinen
  2017-05-04 16:08 ` Joe Perches
  0 siblings, 1 reply; 2+ messages in thread
From: Simo Koskinen @ 2017-05-04 15:33 UTC (permalink / raw)
  To: forest; +Cc: gregkh, devel, linux-kernel, Simo Koskinen

Fixed coding style warnings reported by checkpatch.pl.

Signed-off-by: Simo Koskinen <koskisoft@gmail.com>
---
 drivers/staging/vt6656/rxtx.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 6341349..2609c1e 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -123,10 +123,12 @@ static u32 vnt_get_rsvtime(struct vnt_private *priv, u8 pkt_type,
 
 	if (pkt_type == PK_TYPE_11B)
 		ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
-					      14, (u16)priv->top_cck_basic_rate);
+					      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);
+					      14,
+					      (u16)priv->top_ofdm_basic_rate);
 
 	if (need_ack)
 		return data_time + priv->sifs + ack_time;
@@ -142,7 +144,8 @@ static __le16 vnt_rxtx_rsvtime_le16(struct vnt_private *priv, u8 pkt_type,
 }
 
 static __le16 vnt_get_rtscts_rsvtime_le(struct vnt_private *priv,
-					 u8 rsv_type, u8 pkt_type, u32 frame_length, u16 current_rate)
+					 u8 rsv_type, u8 pkt_type,
+					 u32 frame_length, u16 current_rate)
 {
 	u32 rrv_time, rts_time, cts_time, ack_time, data_time;
 
@@ -227,7 +230,8 @@ static __le16 vnt_get_rtscts_duration_le(struct vnt_usb_send_context *context,
 	case RTSDUR_AA_F0:
 	case RTSDUR_AA_F1:
 		cts_time = vnt_get_frame_time(priv->preamble_type,
-					      pkt_type, 14, priv->top_ofdm_basic_rate);
+					      pkt_type, 14,
+					      priv->top_ofdm_basic_rate);
 		dur_time = cts_time + 2 * priv->sifs +
 			vnt_get_rsvtime(priv, pkt_type,
 					frame_length, rate, need_ack);
@@ -684,7 +688,8 @@ static u16 vnt_rxtx_ab(struct vnt_usb_send_context *tx_context,
 
 static u16 vnt_generate_tx_parameter(struct vnt_usb_send_context *tx_context,
 				      struct vnt_tx_buffer *tx_buffer,
-				      struct vnt_mic_hdr **mic_hdr, u32 need_mic,
+				      struct vnt_mic_hdr **mic_hdr,
+				      u32 need_mic,
 				      bool need_rts)
 {
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] vt6656: Coding style fixes
  2017-05-04 15:33 [PATCH] vt6656: Coding style fixes Simo Koskinen
@ 2017-05-04 16:08 ` Joe Perches
  0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2017-05-04 16:08 UTC (permalink / raw)
  To: Simo Koskinen, forest; +Cc: gregkh, devel, linux-kernel

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-05-04 16:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-04 15:33 [PATCH] vt6656: Coding style fixes Simo Koskinen
2017-05-04 16:08 ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox