Skip to content

Commit 0da6edb

Browse files
shemmingerdavem330
authored andcommitted
hv_netvsc: remove open_cnt reference count
There is only ever a single instance of network device object referencing the internal rndis object. Therefore the open_cnt atomic is not necessary. Signed-off-by: Stephen Hemminger <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 345ac08 commit 0da6edb

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

drivers/net/hyperv/hyperv_net.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -823,8 +823,6 @@ struct netvsc_device {
823823
u32 max_pkt; /* max number of pkt in one send, e.g. 8 */
824824
u32 pkt_align; /* alignment bytes, e.g. 8 */
825825

826-
atomic_t open_cnt;
827-
828826
struct netvsc_channel chan_table[VRSS_CHANNEL_MAX];
829827

830828
struct rcu_head rcu;

drivers/net/hyperv/netvsc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static struct netvsc_device *alloc_net_device(void)
7373

7474
init_waitqueue_head(&net_device->wait_drain);
7575
net_device->destroy = false;
76-
atomic_set(&net_device->open_cnt, 0);
76+
7777
net_device->max_pkt = RNDIS_MAX_PKT_DEFAULT;
7878
net_device->pkt_align = RNDIS_PKT_ALIGN_DEFAULT;
7979

drivers/net/hyperv/rndis_filter.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,9 +1362,6 @@ int rndis_filter_open(struct netvsc_device *nvdev)
13621362
if (!nvdev)
13631363
return -EINVAL;
13641364

1365-
if (atomic_inc_return(&nvdev->open_cnt) != 1)
1366-
return 0;
1367-
13681365
return rndis_filter_open_device(nvdev->extension);
13691366
}
13701367

@@ -1373,13 +1370,12 @@ int rndis_filter_close(struct netvsc_device *nvdev)
13731370
if (!nvdev)
13741371
return -EINVAL;
13751372

1376-
if (atomic_dec_return(&nvdev->open_cnt) != 0)
1377-
return 0;
1378-
13791373
return rndis_filter_close_device(nvdev->extension);
13801374
}
13811375

13821376
bool rndis_filter_opened(const struct netvsc_device *nvdev)
13831377
{
1384-
return atomic_read(&nvdev->open_cnt) > 0;
1378+
const struct rndis_device *dev = nvdev->extension;
1379+
1380+
return dev->state == RNDIS_DEV_DATAINITIALIZED;
13851381
}

0 commit comments

Comments
 (0)