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
71041520
Commit
71041520
authored
Aug 02, 2002
by
Kai Germaschewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ISDN: Clean up creating ISDN net devices
parent
e991a288
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
67 deletions
+44
-67
drivers/isdn/i4l/isdn_common.c
drivers/isdn/i4l/isdn_common.c
+13
-32
drivers/isdn/i4l/isdn_net.c
drivers/isdn/i4l/isdn_net.c
+29
-33
drivers/isdn/i4l/isdn_net.h
drivers/isdn/i4l/isdn_net.h
+2
-2
No files found.
drivers/isdn/i4l/isdn_common.c
View file @
71041520
...
@@ -1267,10 +1267,9 @@ isdn_ctrl_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
...
@@ -1267,10 +1267,9 @@ isdn_ctrl_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
int
ret
;
int
ret
;
int
i
;
int
i
;
char
*
p
;
char
*
p
;
char
*
s
;
union
iocpar
{
union
iocpar
{
char
name
[
10
];
char
name
[
10
];
char
bname
[
2
2
];
char
bname
[
2
0
];
isdn_ioctl_struct
iocts
;
isdn_ioctl_struct
iocts
;
isdn_net_ioctl_phone
phone
;
isdn_net_ioctl_phone
phone
;
isdn_net_ioctl_cfg
cfg
;
isdn_net_ioctl_cfg
cfg
;
...
@@ -1298,42 +1297,24 @@ isdn_ctrl_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
...
@@ -1298,42 +1297,24 @@ isdn_ctrl_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
#ifdef CONFIG_NETDEVICES
#ifdef CONFIG_NETDEVICES
case
IIOCNETAIF
:
case
IIOCNETAIF
:
/* Add a network-interface */
/* Add a network-interface */
if
(
arg
)
{
if
(
copy_from_user
(
name
,
(
char
*
)
arg
,
sizeof
(
name
)
-
1
))
if
(
copy_from_user
(
name
,
(
char
*
)
arg
,
sizeof
(
name
)))
return
-
EFAULT
;
return
-
EFAULT
;
name
[
sizeof
(
name
)
-
1
]
=
0
;
s
=
name
;
}
else
{
s
=
NULL
;
}
ret
=
down_interruptible
(
&
dev
->
sem
);
ret
=
down_interruptible
(
&
dev
->
sem
);
if
(
ret
)
return
ret
;
if
(
ret
)
if
((
s
=
isdn_net_new
(
s
,
NULL
)))
{
return
ret
;
if
(
copy_to_user
((
char
*
)
arg
,
s
,
strlen
(
s
)
+
1
)){
ret
=
isdn_net_new
(
name
,
NULL
);
ret
=
-
EFAULT
;
}
else
{
ret
=
0
;
}
}
else
ret
=
-
ENODEV
;
up
(
&
dev
->
sem
);
up
(
&
dev
->
sem
);
return
ret
;
return
ret
;
case
IIOCNETASL
:
case
IIOCNETASL
:
/* Add a slave to a network-interface */
/* Add a slave to a network-interface */
if
(
arg
)
{
if
(
copy_from_user
(
bname
,
(
char
*
)
arg
,
sizeof
(
bname
)
-
1
))
if
(
copy_from_user
(
bname
,
(
char
*
)
arg
,
sizeof
(
bname
)
-
1
))
return
-
EFAULT
;
return
-
EFAULT
;
bname
[
sizeof
(
bname
)
-
1
]
=
0
;
}
else
return
-
EINVAL
;
ret
=
down_interruptible
(
&
dev
->
sem
);
ret
=
down_interruptible
(
&
dev
->
sem
);
if
(
ret
)
return
ret
;
if
(
ret
)
if
((
s
=
isdn_net_newslave
(
bname
)))
{
return
ret
;
if
(
copy_to_user
((
char
*
)
arg
,
s
,
strlen
(
s
)
+
1
)){
ret
=
isdn_net_newslave
(
bname
);
ret
=
-
EFAULT
;
}
else
{
ret
=
0
;
}
}
else
ret
=
-
ENODEV
;
up
(
&
dev
->
sem
);
up
(
&
dev
->
sem
);
return
ret
;
return
ret
;
case
IIOCNETDIF
:
case
IIOCNETDIF
:
...
...
drivers/isdn/i4l/isdn_net.c
View file @
71041520
...
@@ -2579,26 +2579,24 @@ isdn_net_force_dial(char *name)
...
@@ -2579,26 +2579,24 @@ isdn_net_force_dial(char *name)
/*
/*
* Allocate a new network-interface and initialize its data structures.
* Allocate a new network-interface and initialize its data structures.
*/
*/
char
*
int
isdn_net_new
(
char
*
name
,
struct
net_device
*
master
)
isdn_net_new
(
char
*
name
,
struct
net_device
*
master
)
{
{
int
retval
;
isdn_net_dev
*
netdev
;
isdn_net_dev
*
netdev
;
/* Avoid creating an existing interface */
/* Avoid creating an existing interface */
if
(
isdn_net_findif
(
name
))
{
if
(
isdn_net_findif
(
name
))
{
printk
(
KERN_WARNING
"isdn_net: interface %s already exists
\n
"
,
name
);
printk
(
KERN_WARNING
"isdn_net: interface %s already exists
\n
"
,
name
);
return
NULL
;
return
-
EEXIST
;
}
}
if
(
!
(
netdev
=
(
isdn_net_dev
*
)
kmalloc
(
sizeof
(
isdn_net_dev
),
GFP_KERNEL
)))
{
if
(
!
(
netdev
=
kmalloc
(
sizeof
(
isdn_net_dev
),
GFP_KERNEL
)))
{
printk
(
KERN_WARNING
"isdn_net: Could not allocate net-device
\n
"
);
printk
(
KERN_WARNING
"isdn_net: Could not allocate net-device
\n
"
);
return
NULL
;
return
-
ENOMEM
;
}
}
memset
(
netdev
,
0
,
sizeof
(
isdn_net_dev
));
memset
(
netdev
,
0
,
sizeof
(
isdn_net_dev
));
if
(
name
==
NULL
)
strcpy
(
netdev
->
local
.
name
,
name
);
strcpy
(
netdev
->
local
.
name
,
" "
);
strcpy
(
netdev
->
dev
.
name
,
name
);
else
strcpy
(
netdev
->
local
.
name
,
name
);
strcpy
(
netdev
->
dev
.
name
,
netdev
->
local
.
name
);
netdev
->
dev
.
priv
=
&
netdev
->
local
;
netdev
->
dev
.
priv
=
&
netdev
->
local
;
netdev
->
dev
.
init
=
isdn_net_init
;
netdev
->
dev
.
init
=
isdn_net_init
;
netdev
->
local
.
p_encap
=
ISDN_NET_ENCAP_RAWIP
;
netdev
->
local
.
p_encap
=
ISDN_NET_ENCAP_RAWIP
;
...
@@ -2621,10 +2619,11 @@ isdn_net_new(char *name, struct net_device *master)
...
@@ -2621,10 +2619,11 @@ isdn_net_new(char *name, struct net_device *master)
*/
*/
netdev
->
dev
.
tx_timeout
=
isdn_net_tx_timeout
;
netdev
->
dev
.
tx_timeout
=
isdn_net_tx_timeout
;
netdev
->
dev
.
watchdog_timeo
=
ISDN_NET_TX_TIMEOUT
;
netdev
->
dev
.
watchdog_timeo
=
ISDN_NET_TX_TIMEOUT
;
if
(
register_netdev
(
&
netdev
->
dev
)
!=
0
)
{
retval
=
register_netdev
(
&
netdev
->
dev
);
if
(
retval
)
{
printk
(
KERN_WARNING
"isdn_net: Could not register net-device
\n
"
);
printk
(
KERN_WARNING
"isdn_net: Could not register net-device
\n
"
);
kfree
(
netdev
);
kfree
(
netdev
);
return
NULL
;
return
retval
;
}
}
}
}
netdev
->
local
.
magic
=
ISDN_NET_MAGIC
;
netdev
->
local
.
magic
=
ISDN_NET_MAGIC
;
...
@@ -2665,34 +2664,31 @@ isdn_net_new(char *name, struct net_device *master)
...
@@ -2665,34 +2664,31 @@ isdn_net_new(char *name, struct net_device *master)
/* Put into to netdev-chain */
/* Put into to netdev-chain */
list_add
(
&
netdev
->
global_list
,
&
isdn_net_devs
);
list_add
(
&
netdev
->
global_list
,
&
isdn_net_devs
);
return
netdev
->
dev
.
name
;
return
0
;
}
}
char
*
int
isdn_net_newslave
(
char
*
parm
)
isdn_net_newslave
(
char
*
parm
)
{
{
char
*
p
=
strchr
(
parm
,
','
);
char
*
p
=
strchr
(
parm
,
','
);
isdn_net_dev
*
n
;
isdn_net_dev
*
m
;
char
newname
[
10
];
if
(
p
)
{
/* Slave-Name MUST not be empty */
/* Slave-Name MUST not be empty */
if
(
!
p
||
!
p
[
1
])
if
(
!
strlen
(
p
+
1
))
return
-
EINVAL
;
return
NULL
;
strcpy
(
newname
,
p
+
1
);
*
p
=
0
;
*
p
=
0
;
/* Master must already exist */
/* Master must already exist */
if
(
!
(
m
=
isdn_net_findif
(
parm
)))
if
(
!
(
n
=
isdn_net_findif
(
parm
)))
return
-
ESRCH
;
return
NULL
;
/* Master must be a real interface, not a slave */
/* Master must be a real interface, not a slave */
if
(
m
->
local
.
master
)
if
(
n
->
local
.
master
)
return
-
ENXIO
;
return
NULL
;
/* Master must not be started yet */
/* Master must not be started yet */
if
(
isdn_net_device_started
(
m
))
if
(
isdn_net_device_started
(
n
))
return
-
EBUSY
;
return
NULL
;
return
(
isdn_net_new
(
newname
,
&
(
n
->
dev
)));
return
isdn_net_new
(
p
+
1
,
&
m
->
dev
);
}
return
NULL
;
}
}
/*
/*
...
...
drivers/isdn/i4l/isdn_net.h
View file @
71041520
...
@@ -31,8 +31,8 @@
...
@@ -31,8 +31,8 @@
#define CISCO_SLARP_REPLY 1
#define CISCO_SLARP_REPLY 1
#define CISCO_SLARP_KEEPALIVE 2
#define CISCO_SLARP_KEEPALIVE 2
extern
char
*
isdn_net_new
(
char
*
,
struct
net_device
*
);
extern
int
isdn_net_new
(
char
*
,
struct
net_device
*
);
extern
char
*
isdn_net_newslave
(
char
*
);
extern
int
isdn_net_newslave
(
char
*
);
extern
int
isdn_net_rm
(
char
*
);
extern
int
isdn_net_rm
(
char
*
);
extern
int
isdn_net_rmall
(
void
);
extern
int
isdn_net_rmall
(
void
);
extern
int
isdn_net_stat_callback
(
int
,
isdn_ctrl
*
);
extern
int
isdn_net_stat_callback
(
int
,
isdn_ctrl
*
);
...
...
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