Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
921d6227
Commit
921d6227
authored
Jun 16, 2003
by
Stephen Hemminger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NET]: alloc_netdev for shaper.
parent
06b4a180
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
19 deletions
+18
-19
drivers/net/shaper.c
drivers/net/shaper.c
+18
-19
No files found.
drivers/net/shaper.c
View file @
921d6227
...
@@ -630,7 +630,7 @@ static void shaper_init_priv(struct net_device *dev)
...
@@ -630,7 +630,7 @@ static void shaper_init_priv(struct net_device *dev)
* Add a shaper device to the system
* Add a shaper device to the system
*/
*/
static
int
__init
shaper_probe
(
struct
net_device
*
dev
)
static
void
__init
shaper_setup
(
struct
net_device
*
dev
)
{
{
/*
/*
* Set up the shaper.
* Set up the shaper.
...
@@ -642,6 +642,7 @@ static int __init shaper_probe(struct net_device *dev)
...
@@ -642,6 +642,7 @@ static int __init shaper_probe(struct net_device *dev)
dev
->
open
=
shaper_open
;
dev
->
open
=
shaper_open
;
dev
->
stop
=
shaper_close
;
dev
->
stop
=
shaper_close
;
dev
->
destructor
=
(
void
(
*
)(
struct
net_device
*
))
kfree
;
dev
->
hard_start_xmit
=
shaper_start_xmit
;
dev
->
hard_start_xmit
=
shaper_start_xmit
;
dev
->
get_stats
=
shaper_get_stats
;
dev
->
get_stats
=
shaper_get_stats
;
dev
->
set_multicast_list
=
NULL
;
dev
->
set_multicast_list
=
NULL
;
...
@@ -669,12 +670,6 @@ static int __init shaper_probe(struct net_device *dev)
...
@@ -669,12 +670,6 @@ static int __init shaper_probe(struct net_device *dev)
dev
->
addr_len
=
0
;
dev
->
addr_len
=
0
;
dev
->
tx_queue_len
=
10
;
dev
->
tx_queue_len
=
10
;
dev
->
flags
=
0
;
dev
->
flags
=
0
;
/*
* Shaper is ok
*/
return
0
;
}
}
static
int
shapers
=
1
;
static
int
shapers
=
1
;
...
@@ -695,35 +690,38 @@ __setup("shapers=", set_num_shapers);
...
@@ -695,35 +690,38 @@ __setup("shapers=", set_num_shapers);
#endif
/* MODULE */
#endif
/* MODULE */
static
struct
net_device
*
devs
;
static
struct
net_device
*
*
devs
;
static
unsigned
int
shapers_registered
=
0
;
static
unsigned
int
shapers_registered
=
0
;
static
int
__init
shaper_init
(
void
)
static
int
__init
shaper_init
(
void
)
{
{
int
i
,
err
;
int
i
;
size_t
alloc_size
;
size_t
alloc_size
;
struct
shaper
*
sp
;
struct
net_device
*
dev
;
char
name
[
IFNAMSIZ
];
if
(
shapers
<
1
)
if
(
shapers
<
1
)
return
-
ENODEV
;
return
-
ENODEV
;
alloc_size
=
(
sizeof
(
*
devs
)
*
shapers
)
+
alloc_size
=
sizeof
(
*
dev
)
*
shapers
;
(
sizeof
(
struct
shaper
)
*
shapers
);
devs
=
kmalloc
(
alloc_size
,
GFP_KERNEL
);
devs
=
kmalloc
(
alloc_size
,
GFP_KERNEL
);
if
(
!
devs
)
if
(
!
devs
)
return
-
ENOMEM
;
return
-
ENOMEM
;
memset
(
devs
,
0
,
alloc_size
);
memset
(
devs
,
0
,
alloc_size
);
sp
=
(
struct
shaper
*
)
&
devs
[
shapers
];
for
(
i
=
0
;
i
<
shapers
;
i
++
)
{
for
(
i
=
0
;
i
<
shapers
;
i
++
)
{
err
=
dev_alloc_name
(
&
devs
[
i
],
"shaper%d"
);
if
(
err
<
0
)
snprintf
(
name
,
IFNAMSIZ
,
"shaper%d"
,
i
);
dev
=
alloc_netdev
(
sizeof
(
struct
shaper
),
name
,
shaper_setup
);
if
(
!
dev
)
break
;
break
;
devs
[
i
].
init
=
shaper_probe
;
devs
[
i
].
priv
=
&
sp
[
i
];
if
(
register_netdev
(
dev
))
if
(
register_netdev
(
&
devs
[
i
]))
break
;
break
;
devs
[
i
]
=
dev
;
shapers_registered
++
;
shapers_registered
++
;
}
}
...
@@ -740,7 +738,8 @@ static void __exit shaper_exit (void)
...
@@ -740,7 +738,8 @@ static void __exit shaper_exit (void)
int
i
;
int
i
;
for
(
i
=
0
;
i
<
shapers_registered
;
i
++
)
for
(
i
=
0
;
i
<
shapers_registered
;
i
++
)
unregister_netdev
(
&
devs
[
i
]);
if
(
devs
[
i
])
unregister_netdev
(
devs
[
i
]);
kfree
(
devs
);
kfree
(
devs
);
devs
=
NULL
;
devs
=
NULL
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment