public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber•org>
To: kys@microsoft•com, haiyangz@microsoft•com, sthemmin@microsoft•com
Cc: devel@linuxdriverproject•org, netdev@vger•kernel.org
Subject: [PATCH net-next 5/6] netvsc: pass net_device to netvsc_init_buf and netvsc_connect_vsp
Date: Thu,  8 Jun 2017 16:21:22 -0700	[thread overview]
Message-ID: <20170608232123.28366-6-sthemmin@microsoft.com> (raw)
In-Reply-To: <20170608232123.28366-1-sthemmin@microsoft.com>

Don't need to find netvsc_device structure, caller already had it.
Also rearrange declarations.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft•com>
---
 drivers/net/hyperv/netvsc.c | 31 +++++++++++--------------------
 1 file changed, 11 insertions(+), 20 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index caf89a245ba6..4d4fde0c7974 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -243,18 +243,15 @@ static void netvsc_destroy_buf(struct hv_device *device)
 	kfree(net_device->send_section_map);
 }
 
-static int netvsc_init_buf(struct hv_device *device)
+static int netvsc_init_buf(struct hv_device *device,
+			   struct netvsc_device *net_device)
 {
 	int ret = 0;
-	struct netvsc_device *net_device;
 	struct nvsp_message *init_packet;
 	struct net_device *ndev;
 	size_t map_words;
 	int node;
 
-	net_device = get_outbound_net_device(device);
-	if (!net_device)
-		return -ENODEV;
 	ndev = hv_get_drvdata(device);
 
 	node = cpu_to_node(device->channel->target_cpu);
@@ -285,9 +282,7 @@ static int netvsc_init_buf(struct hv_device *device)
 
 	/* Notify the NetVsp of the gpadl handle */
 	init_packet = &net_device->channel_init_pkt;
-
 	memset(init_packet, 0, sizeof(struct nvsp_message));
-
 	init_packet->hdr.msg_type = NVSP_MSG1_TYPE_SEND_RECV_BUF;
 	init_packet->msg.v1_msg.send_recv_buf.
 		gpadl_handle = net_device->recv_buf_gpadl_handle;
@@ -486,20 +481,15 @@ static int negotiate_nvsp_ver(struct hv_device *device,
 	return ret;
 }
 
-static int netvsc_connect_vsp(struct hv_device *device)
+static int netvsc_connect_vsp(struct hv_device *device,
+			      struct netvsc_device *net_device)
 {
-	int ret;
-	struct netvsc_device *net_device;
-	struct nvsp_message *init_packet;
-	int ndis_version;
 	const u32 ver_list[] = {
 		NVSP_PROTOCOL_VERSION_1, NVSP_PROTOCOL_VERSION_2,
-		NVSP_PROTOCOL_VERSION_4, NVSP_PROTOCOL_VERSION_5 };
-	int i;
-
-	net_device = get_outbound_net_device(device);
-	if (!net_device)
-		return -ENODEV;
+		NVSP_PROTOCOL_VERSION_4, NVSP_PROTOCOL_VERSION_5
+	};
+	struct nvsp_message *init_packet;
+	int ndis_version, i, ret;
 
 	init_packet = &net_device->channel_init_pkt;
 
@@ -549,7 +539,7 @@ static int netvsc_connect_vsp(struct hv_device *device)
 		net_device->recv_buf_size = NETVSC_RECEIVE_BUFFER_SIZE;
 	net_device->send_buf_size = NETVSC_SEND_BUFFER_SIZE;
 
-	ret = netvsc_init_buf(device);
+	ret = netvsc_init_buf(device, net_device);
 
 cleanup:
 	return ret;
@@ -1349,7 +1339,7 @@ int netvsc_device_add(struct hv_device *device,
 	rcu_assign_pointer(net_device_ctx->nvdev, net_device);
 
 	/* Connect with the NetVsp */
-	ret = netvsc_connect_vsp(device);
+	ret = netvsc_connect_vsp(device, net_device);
 	if (ret != 0) {
 		netdev_err(ndev,
 			"unable to connect to NetVSP - %d\n", ret);
@@ -1368,4 +1358,5 @@ int netvsc_device_add(struct hv_device *device,
 	free_netvsc_device(&net_device->rcu);
 
 	return ret;
+
 }
-- 
2.11.0

  parent reply	other threads:[~2017-06-08 23:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-08 23:21 [PATCH net-next 0/6] netvsc: small cleanups Stephen Hemminger
2017-06-08 23:21 ` [PATCH net-next 1/6] netvsc: optimize calculation of number of slots Stephen Hemminger
2017-06-08 23:21 ` [PATCH net-next 2/6] netvsc: use hv_get_bytes_to_read Stephen Hemminger
2017-06-08 23:21 ` [PATCH net-next 3/6] netvsc: use typed pointer for internal state Stephen Hemminger
2017-06-09 10:24   ` Sergei Shtylyov
2017-06-08 23:21 ` [PATCH net-next 4/6] netvsc: mark error cases as unlikely Stephen Hemminger
2017-06-08 23:21 ` Stephen Hemminger [this message]
2017-06-08 23:21 ` [PATCH net-next 6/6] netvsc: fold in get_outbound_net_device Stephen Hemminger
2017-06-09 16:16 ` [PATCH net-next 0/6] netvsc: small cleanups David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170608232123.28366-6-sthemmin@microsoft.com \
    --to=stephen@networkplumber$(echo .)org \
    --cc=devel@linuxdriverproject$(echo .)org \
    --cc=haiyangz@microsoft$(echo .)com \
    --cc=kys@microsoft$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=sthemmin@microsoft$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox