Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1700258 > unrolled thread

[PATCH V2] hyperv: netvsc: Neaten netvsc_send_pkt by using a temporary

Started byJoe Perches <joe@perches.com>
First post2017-07-31 19:40 +0200
Last post2017-08-02 19:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH V2] hyperv: netvsc: Neaten netvsc_send_pkt by using a temporary Joe Perches <joe@perches.com> - 2017-07-31 19:40 +0200
    Re: [PATCH V2] hyperv: netvsc: Neaten netvsc_send_pkt by using a  temporary David Miller <davem@davemloft.net> - 2017-08-02 19:40 +0200

#1700258 — [PATCH V2] hyperv: netvsc: Neaten netvsc_send_pkt by using a temporary

FromJoe Perches <joe@perches.com>
Date2017-07-31 19:40 +0200
Subject[PATCH V2] hyperv: netvsc: Neaten netvsc_send_pkt by using a temporary
Message-ID<u9mPF-H2-37@gated-at.bofh.it>
Repeated dereference of nvmsg.msg.v1_msg.send_rndis_pkt can be
shortened by using a temporary.  Do so.

No change in object code.

Miscellanea:

o Use * const for rpkt and nvchan

Signed-off-by: Joe Perches <joe@perches.com>
---

v2: Use * const for rpkt and nvchan
      This is a fairly unusual style, but is technically correct
      requested by: Stephen Hemminger <stephen@networkplumber.org>
    Removed style change that doesn't apply any longer

 drivers/net/hyperv/netvsc.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index c64934c64dca..9598220b3bcc 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -747,8 +747,10 @@ static inline int netvsc_send_pkt(
 	struct sk_buff *skb)
 {
 	struct nvsp_message nvmsg;
-	struct netvsc_channel *nvchan
-		= &net_device->chan_table[packet->q_idx];
+	struct nvsp_1_message_send_rndis_packet * const rpkt =
+		&nvmsg.msg.v1_msg.send_rndis_pkt;
+	struct netvsc_channel * const nvchan =
+		&net_device->chan_table[packet->q_idx];
 	struct vmbus_channel *out_channel = nvchan->channel;
 	struct net_device *ndev = hv_get_drvdata(device);
 	struct netdev_queue *txq = netdev_get_tx_queue(ndev, packet->q_idx);
@@ -757,21 +759,16 @@ static inline int netvsc_send_pkt(
 	u32 ring_avail = hv_ringbuf_avail_percent(&out_channel->outbound);
 
 	nvmsg.hdr.msg_type = NVSP_MSG1_TYPE_SEND_RNDIS_PKT;
-	if (skb != NULL) {
-		/* 0 is RMC_DATA; */
-		nvmsg.msg.v1_msg.send_rndis_pkt.channel_type = 0;
-	} else {
-		/* 1 is RMC_CONTROL; */
-		nvmsg.msg.v1_msg.send_rndis_pkt.channel_type = 1;
-	}
+	if (skb)
+		rpkt->channel_type = 0;		/* 0 is RMC_DATA */
+	else
+		rpkt->channel_type = 1;		/* 1 is RMC_CONTROL */
 
-	nvmsg.msg.v1_msg.send_rndis_pkt.send_buf_section_index =
-		packet->send_buf_index;
+	rpkt->send_buf_section_index = packet->send_buf_index;
 	if (packet->send_buf_index == NETVSC_INVALID_INDEX)
-		nvmsg.msg.v1_msg.send_rndis_pkt.send_buf_section_size = 0;
+		rpkt->send_buf_section_size = 0;
 	else
-		nvmsg.msg.v1_msg.send_rndis_pkt.send_buf_section_size =
-			packet->total_data_buflen;
+		rpkt->send_buf_section_size = packet->total_data_buflen;
 
 	req_id = (ulong)skb;
 
-- 
2.10.0.rc2.1.g053435c

[toc] | [next] | [standalone]


#1702326 — Re: [PATCH V2] hyperv: netvsc: Neaten netvsc_send_pkt by using a temporary

FromDavid Miller <davem@davemloft.net>
Date2017-08-02 19:40 +0200
SubjectRe: [PATCH V2] hyperv: netvsc: Neaten netvsc_send_pkt by using a temporary
Message-ID<ua5MK-4w6-27@gated-at.bofh.it>
In reply to#1700258
From: Joe Perches <joe@perches.com>
Date: Mon, 31 Jul 2017 10:30:54 -0700

> Repeated dereference of nvmsg.msg.v1_msg.send_rndis_pkt can be
> shortened by using a temporary.  Do so.
> 
> No change in object code.
> 
> Miscellanea:
> 
> o Use * const for rpkt and nvchan
> 
> Signed-off-by: Joe Perches <joe@perches.com>

Applied to net-next.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web