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
Kirill Smelkov
linux
Commits
d65b155e
Commit
d65b155e
authored
Jan 10, 2004
by
Alexander Viro
Committed by
Stephen Hemminger
Jan 10, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[netdrvr ppp] netdev dynamic alloc; convert ppp_net_init to alloc_netdev setup function
parent
5d572ab0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
36 deletions
+31
-36
drivers/net/ppp_generic.c
drivers/net/ppp_generic.c
+31
-36
No files found.
drivers/net/ppp_generic.c
View file @
d65b155e
...
...
@@ -917,19 +917,14 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
return
err
;
}
static
int
ppp_net_init
(
struct
net_device
*
dev
)
static
void
ppp_setup
(
struct
net_device
*
dev
)
{
dev
->
hard_header_len
=
PPP_HDRLEN
;
dev
->
mtu
=
PPP_MTU
;
dev
->
hard_start_xmit
=
ppp_start_xmit
;
dev
->
get_stats
=
ppp_net_stats
;
dev
->
do_ioctl
=
ppp_net_ioctl
;
dev
->
addr_len
=
0
;
dev
->
tx_queue_len
=
3
;
dev
->
type
=
ARPHRD_PPP
;
dev
->
flags
=
IFF_POINTOPOINT
|
IFF_NOARP
|
IFF_MULTICAST
;
return
0
;
}
/*
...
...
@@ -2272,23 +2267,13 @@ ppp_create_interface(int unit, int *retp)
int
i
;
ppp
=
kmalloc
(
sizeof
(
struct
ppp
),
GFP_KERNEL
);
if
(
ppp
==
0
)
goto
err
;
dev
=
kmalloc
(
sizeof
(
struct
net_device
),
GFP_KERNEL
);
if
(
dev
==
0
)
goto
err
;
if
(
!
ppp
)
goto
out
;
dev
=
alloc_netdev
(
0
,
""
,
ppp_setup
);
if
(
!
dev
)
goto
out1
;
memset
(
ppp
,
0
,
sizeof
(
struct
ppp
));
memset
(
dev
,
0
,
sizeof
(
struct
net_device
));
ret
=
-
EEXIST
;
down
(
&
all_ppp_sem
);
if
(
unit
<
0
)
unit
=
cardmap_find_first_free
(
all_ppp_units
);
else
if
(
cardmap_get
(
all_ppp_units
,
unit
)
!=
NULL
)
goto
err_unlock
;
/* unit already exists */
/* Initialize the new ppp unit */
ppp
->
file
.
index
=
unit
;
ppp
->
mru
=
PPP_MRU
;
init_ppp_file
(
&
ppp
->
file
,
INTERFACE
);
ppp
->
file
.
hdrlen
=
PPP_HDRLEN
-
2
;
/* don't count proto bytes */
...
...
@@ -2301,20 +2286,29 @@ ppp_create_interface(int unit, int *retp)
ppp
->
minseq
=
-
1
;
skb_queue_head_init
(
&
ppp
->
mrq
);
#endif
/* CONFIG_PPP_MULTILINK */
ppp
->
dev
=
dev
;
dev
->
init
=
ppp_net_init
;
sprintf
(
dev
->
name
,
"ppp%d"
,
unit
);
dev
->
priv
=
ppp
;
dev
->
destructor
=
free_netdev
;
rtnl_lock
();
ret
=
register_netdevice
(
dev
);
rtnl_unlock
();
dev
->
hard_start_xmit
=
ppp_start_xmit
;
dev
->
get_stats
=
ppp_net_stats
;
dev
->
do_ioctl
=
ppp_net_ioctl
;
ret
=
-
EEXIST
;
down
(
&
all_ppp_sem
);
if
(
unit
<
0
)
unit
=
cardmap_find_first_free
(
all_ppp_units
);
else
if
(
cardmap_get
(
all_ppp_units
,
unit
)
!=
NULL
)
goto
out2
;
/* unit already exists */
/* Initialize the new ppp unit */
ppp
->
file
.
index
=
unit
;
sprintf
(
dev
->
name
,
"ppp%d"
,
unit
);
ret
=
register_netdev
(
dev
);
if
(
ret
!=
0
)
{
printk
(
KERN_ERR
"PPP: couldn't register device %s (%d)
\n
"
,
dev
->
name
,
ret
);
goto
err_unlock
;
goto
out2
;
}
atomic_inc
(
&
ppp_unit_count
);
...
...
@@ -2323,14 +2317,13 @@ ppp_create_interface(int unit, int *retp)
*
retp
=
0
;
return
ppp
;
err_unlock
:
out2
:
up
(
&
all_ppp_sem
);
err:
free_netdev
(
dev
);
out1:
kfree
(
ppp
);
out:
*
retp
=
ret
;
if
(
ppp
)
kfree
(
ppp
);
if
(
dev
)
kfree
(
dev
);
return
NULL
;
}
...
...
@@ -2361,8 +2354,10 @@ static void ppp_shutdown_interface(struct ppp *ppp)
ppp
->
dev
=
0
;
ppp_unlock
(
ppp
);
/* This will call dev_close() for us. */
if
(
dev
)
if
(
dev
)
{
unregister_netdev
(
dev
);
free_netdev
(
dev
);
}
cardmap_set
(
&
all_ppp_units
,
ppp
->
file
.
index
,
NULL
);
ppp
->
file
.
dead
=
1
;
ppp
->
owner
=
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