File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33obj-$(CONFIG_NETDEVSIM) += netdevsim.o
44
55netdevsim-objs := \
6- netdev.o dev.o fib.o sdev.o
6+ netdev.o dev.o fib.o sdev.o bus.o
77
88ifeq ($(CONFIG_BPF_SYSCALL ) ,y)
99netdevsim-objs += \
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: GPL-2.0
2+ /* Copyright (C) 2017 Netronome Systems, Inc.
3+ * Copyright (C) 2019 Mellanox Technologies. All rights reserved
4+ */
5+
6+ #include <linux/device.h>
7+
8+ #include "netdevsim.h"
9+
10+ struct bus_type nsim_bus = {
11+ .name = DRV_NAME ,
12+ .dev_name = DRV_NAME ,
13+ .num_vf = nsim_num_vf ,
14+ };
15+
16+ int nsim_bus_init (void )
17+ {
18+ return bus_register (& nsim_bus );
19+ }
20+
21+ void nsim_bus_exit (void )
22+ {
23+ bus_unregister (& nsim_bus );
24+ }
Original file line number Diff line number Diff line change @@ -42,19 +42,13 @@ struct nsim_vf_config {
4242
4343static struct dentry * nsim_ddir ;
4444
45- static int nsim_num_vf (struct device * dev )
45+ int nsim_num_vf (struct device * dev )
4646{
4747 struct netdevsim * ns = to_nsim (dev );
4848
4949 return ns -> num_vfs ;
5050}
5151
52- static struct bus_type nsim_bus = {
53- .name = DRV_NAME ,
54- .dev_name = DRV_NAME ,
55- .num_vf = nsim_num_vf ,
56- };
57-
5852static int nsim_vfs_enable (struct netdevsim * ns , unsigned int num_vfs )
5953{
6054 ns -> vfconfigs = kcalloc (num_vfs , sizeof (struct nsim_vf_config ),
@@ -544,18 +538,18 @@ static int __init nsim_module_init(void)
544538 if (err )
545539 goto err_debugfs_destroy ;
546540
547- err = bus_register ( & nsim_bus );
541+ err = nsim_bus_init ( );
548542 if (err )
549543 goto err_sdev_exit ;
550544
551545 err = rtnl_link_register (& nsim_link_ops );
552546 if (err )
553- goto err_unreg_bus ;
547+ goto err_bus_exit ;
554548
555549 return 0 ;
556550
557- err_unreg_bus :
558- bus_unregister ( & nsim_bus );
551+ err_bus_exit :
552+ nsim_bus_exit ( );
559553err_sdev_exit :
560554 nsim_sdev_exit ();
561555err_debugfs_destroy :
@@ -566,7 +560,7 @@ static int __init nsim_module_init(void)
566560static void __exit nsim_module_exit (void )
567561{
568562 rtnl_link_unregister (& nsim_link_ops );
569- bus_unregister ( & nsim_bus );
563+ nsim_bus_exit ( );
570564 nsim_sdev_exit ();
571565 debugfs_remove_recursive (nsim_ddir );
572566}
Original file line number Diff line number Diff line change @@ -188,3 +188,10 @@ static inline struct netdevsim *to_nsim(struct device *ptr)
188188{
189189 return container_of (ptr , struct netdevsim , dev );
190190}
191+
192+ int nsim_num_vf (struct device * dev );
193+
194+ extern struct bus_type nsim_bus ;
195+
196+ int nsim_bus_init (void );
197+ void nsim_bus_exit (void );
You can’t perform that action at this time.
0 commit comments