Skip to content

Commit 9579083

Browse files
shemmingerdavem330
authored andcommitted
netvsc: pass net_device to netvsc_init_buf and netvsc_connect_vsp
Don't need to find netvsc_device structure, caller already had it. Also rearrange declarations. Signed-off-by: Stephen Hemminger <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2d694d2 commit 9579083

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

drivers/net/hyperv/netvsc.c

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -243,18 +243,15 @@ static void netvsc_destroy_buf(struct hv_device *device)
243243
kfree(net_device->send_section_map);
244244
}
245245

246-
static int netvsc_init_buf(struct hv_device *device)
246+
static int netvsc_init_buf(struct hv_device *device,
247+
struct netvsc_device *net_device)
247248
{
248249
int ret = 0;
249-
struct netvsc_device *net_device;
250250
struct nvsp_message *init_packet;
251251
struct net_device *ndev;
252252
size_t map_words;
253253
int node;
254254

255-
net_device = get_outbound_net_device(device);
256-
if (!net_device)
257-
return -ENODEV;
258255
ndev = hv_get_drvdata(device);
259256

260257
node = cpu_to_node(device->channel->target_cpu);
@@ -285,9 +282,7 @@ static int netvsc_init_buf(struct hv_device *device)
285282

286283
/* Notify the NetVsp of the gpadl handle */
287284
init_packet = &net_device->channel_init_pkt;
288-
289285
memset(init_packet, 0, sizeof(struct nvsp_message));
290-
291286
init_packet->hdr.msg_type = NVSP_MSG1_TYPE_SEND_RECV_BUF;
292287
init_packet->msg.v1_msg.send_recv_buf.
293288
gpadl_handle = net_device->recv_buf_gpadl_handle;
@@ -486,20 +481,15 @@ static int negotiate_nvsp_ver(struct hv_device *device,
486481
return ret;
487482
}
488483

489-
static int netvsc_connect_vsp(struct hv_device *device)
484+
static int netvsc_connect_vsp(struct hv_device *device,
485+
struct netvsc_device *net_device)
490486
{
491-
int ret;
492-
struct netvsc_device *net_device;
493-
struct nvsp_message *init_packet;
494-
int ndis_version;
495487
const u32 ver_list[] = {
496488
NVSP_PROTOCOL_VERSION_1, NVSP_PROTOCOL_VERSION_2,
497-
NVSP_PROTOCOL_VERSION_4, NVSP_PROTOCOL_VERSION_5 };
498-
int i;
499-
500-
net_device = get_outbound_net_device(device);
501-
if (!net_device)
502-
return -ENODEV;
489+
NVSP_PROTOCOL_VERSION_4, NVSP_PROTOCOL_VERSION_5
490+
};
491+
struct nvsp_message *init_packet;
492+
int ndis_version, i, ret;
503493

504494
init_packet = &net_device->channel_init_pkt;
505495

@@ -549,7 +539,7 @@ static int netvsc_connect_vsp(struct hv_device *device)
549539
net_device->recv_buf_size = NETVSC_RECEIVE_BUFFER_SIZE;
550540
net_device->send_buf_size = NETVSC_SEND_BUFFER_SIZE;
551541

552-
ret = netvsc_init_buf(device);
542+
ret = netvsc_init_buf(device, net_device);
553543

554544
cleanup:
555545
return ret;
@@ -1349,7 +1339,7 @@ int netvsc_device_add(struct hv_device *device,
13491339
rcu_assign_pointer(net_device_ctx->nvdev, net_device);
13501340

13511341
/* Connect with the NetVsp */
1352-
ret = netvsc_connect_vsp(device);
1342+
ret = netvsc_connect_vsp(device, net_device);
13531343
if (ret != 0) {
13541344
netdev_err(ndev,
13551345
"unable to connect to NetVSP - %d\n", ret);
@@ -1368,4 +1358,5 @@ int netvsc_device_add(struct hv_device *device,
13681358
free_netvsc_device(&net_device->rcu);
13691359

13701360
return ret;
1361+
13711362
}

0 commit comments

Comments
 (0)