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
e9123b30
Commit
e9123b30
authored
May 06, 2002
by
Kai Germaschewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ISDN: CAPI: use <linux/list.h> lists
parent
64cf5d05
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
89 deletions
+82
-89
drivers/isdn/capi/kcapi.c
drivers/isdn/capi/kcapi.c
+64
-81
drivers/isdn/hardware/avm/b1pcmcia.c
drivers/isdn/hardware/avm/b1pcmcia.c
+4
-2
drivers/isdn/hardware/avm/t1isa.c
drivers/isdn/hardware/avm/t1isa.c
+6
-2
include/linux/isdn/capilli.h
include/linux/isdn/capilli.h
+5
-3
include/linux/kernelcapi.h
include/linux/kernelcapi.h
+3
-1
No files found.
drivers/isdn/capi/kcapi.c
View file @
e9123b30
...
...
@@ -112,11 +112,13 @@ static char capi_manufakturer[64] = "AVM Berlin";
static
struct
capi_appl
applications
[
CAPI_MAXAPPL
];
static
struct
capi_ctr
cards
[
CAPI_MAXCONTR
];
static
int
ncards
=
0
;
static
int
ncards
;
static
struct
sk_buff_head
recv_queue
;
static
struct
capi_interface_user
*
capi_users
=
0
;
static
spinlock_t
capi_users_lock
=
SPIN_LOCK_UNLOCKED
;
static
struct
capi_driver
*
drivers
;
static
LIST_HEAD
(
users
);
static
spinlock_t
users_lock
=
SPIN_LOCK_UNLOCKED
;
static
LIST_HEAD
(
drivers
);
static
spinlock_t
drivers_lock
=
SPIN_LOCK_UNLOCKED
;
static
struct
tq_struct
tq_state_notify
;
...
...
@@ -276,11 +278,14 @@ static int proc_ncci_read_proc(char *page, char **start, off_t off,
static
int
proc_driver_read_proc
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
int
*
eof
,
void
*
data
)
{
struct
list_head
*
l
;
struct
capi_driver
*
driver
;
int
len
=
0
;
spin_lock
(
&
drivers_lock
);
for
(
driver
=
drivers
;
driver
;
driver
=
driver
->
next
)
{
list_for_each
(
l
,
&
drivers
)
{
driver
=
list_entry
(
l
,
struct
capi_driver
,
driver_list
);
len
+=
sprintf
(
page
+
len
,
"%-32s %d %s
\n
"
,
driver
->
name
,
driver
->
ncontroller
,
...
...
@@ -310,11 +315,13 @@ static int proc_driver_read_proc(char *page, char **start, off_t off,
static
int
proc_users_read_proc
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
int
*
eof
,
void
*
data
)
{
struct
list_head
*
l
;
struct
capi_interface_user
*
cp
;
int
len
=
0
;
spin_lock
(
&
capi_users_lock
);
for
(
cp
=
capi_users
;
cp
;
cp
=
cp
->
next
)
{
spin_lock
(
&
users_lock
);
list_for_each
(
l
,
&
users
)
{
cp
=
list_entry
(
l
,
struct
capi_interface_user
,
user_list
);
len
+=
sprintf
(
page
+
len
,
"%s
\n
"
,
cp
->
name
);
if
(
len
<=
off
)
{
off
-=
len
;
...
...
@@ -325,7 +332,7 @@ static int proc_users_read_proc(char *page, char **start, off_t off,
}
}
endloop:
spin_unlock
(
&
capi_
users_lock
);
spin_unlock
(
&
users_lock
);
*
start
=
page
+
off
;
if
(
len
<
count
)
*
eof
=
1
;
...
...
@@ -596,63 +603,74 @@ static int notify_push(unsigned int cmd, u32 controller,
static
void
notify_up
(
u32
contr
)
{
struct
list_head
*
l
;
struct
capi_interface_user
*
p
;
printk
(
KERN_NOTICE
"kcapi: notify up contr %d
\n
"
,
contr
);
spin_lock
(
&
capi_users_lock
);
for
(
p
=
capi_users
;
p
;
p
=
p
->
next
)
{
spin_lock
(
&
users_lock
);
list_for_each
(
l
,
&
users
)
{
p
=
list_entry
(
l
,
struct
capi_interface_user
,
user_list
);
if
(
!
p
->
callback
)
continue
;
(
*
p
->
callback
)
(
KCI_CONTRUP
,
contr
,
&
CARD
(
contr
)
->
profile
);
}
spin_unlock
(
&
capi_
users_lock
);
spin_unlock
(
&
users_lock
);
}
/* -------- KCI_CONTRDOWN ------------------------------------- */
static
void
notify_down
(
u32
contr
)
{
struct
list_head
*
l
;
struct
capi_interface_user
*
p
;
printk
(
KERN_NOTICE
"kcapi: notify down contr %d
\n
"
,
contr
);
spin_lock
(
&
capi_users_lock
);
for
(
p
=
capi_users
;
p
;
p
=
p
->
next
)
{
spin_lock
(
&
users_lock
);
list_for_each
(
l
,
&
users
)
{
p
=
list_entry
(
l
,
struct
capi_interface_user
,
user_list
);
if
(
!
p
->
callback
)
continue
;
(
*
p
->
callback
)
(
KCI_CONTRDOWN
,
contr
,
0
);
}
spin_unlock
(
&
capi_
users_lock
);
spin_unlock
(
&
users_lock
);
}
/* -------- KCI_NCCIUP ---------------------------------------- */
static
void
notify_ncciup
(
u32
contr
,
u16
applid
,
u32
ncci
)
{
struct
list_head
*
l
;
struct
capi_interface_user
*
p
;
struct
capi_ncciinfo
n
;
n
.
applid
=
applid
;
n
.
ncci
=
ncci
;
/*printk(KERN_NOTICE "kcapi: notify up contr %d\n", contr);*/
spin_lock
(
&
capi_users_lock
);
for
(
p
=
capi_users
;
p
;
p
=
p
->
next
)
{
spin_lock
(
&
users_lock
);
list_for_each
(
l
,
&
users
)
{
p
=
list_entry
(
l
,
struct
capi_interface_user
,
user_list
);
if
(
!
p
->
callback
)
continue
;
(
*
p
->
callback
)
(
KCI_NCCIUP
,
contr
,
&
n
);
}
spin_unlock
(
&
capi_
users_lock
);
spin_unlock
(
&
users_lock
);
};
/* -------- KCI_NCCIDOWN -------------------------------------- */
static
void
notify_nccidown
(
u32
contr
,
u16
applid
,
u32
ncci
)
{
struct
list_head
*
l
;
struct
capi_interface_user
*
p
;
struct
capi_ncciinfo
n
;
n
.
applid
=
applid
;
n
.
ncci
=
ncci
;
/*printk(KERN_NOTICE "kcapi: notify down contr %d\n", contr);*/
spin_lock
(
&
capi_users_lock
);
for
(
p
=
capi_users
;
p
;
p
=
p
->
next
)
{
spin_lock
(
&
users_lock
);
list_for_each
(
l
,
&
users
)
{
p
=
list_entry
(
l
,
struct
capi_interface_user
,
user_list
);
if
(
!
p
->
callback
)
continue
;
(
*
p
->
callback
)
(
KCI_NCCIDOWN
,
contr
,
&
n
);
}
spin_unlock
(
&
capi_
users_lock
);
spin_unlock
(
&
users_lock
);
};
/* ------------------------------------------------------------ */
...
...
@@ -964,7 +982,7 @@ static void controllercb_resume_output(struct capi_ctr *card)
struct
capi_ctr
*
drivercb_attach_ctr
(
struct
capi_driver
*
driver
,
char
*
name
,
void
*
driverdata
)
{
struct
capi_ctr
*
card
,
**
pp
;
struct
capi_ctr
*
card
;
int
i
;
for
(
i
=
0
;
i
<
CAPI_MAXCONTR
&&
cards
[
i
].
cardstate
!=
CARD_FREE
;
i
++
)
;
...
...
@@ -991,9 +1009,7 @@ drivercb_attach_ctr(struct capi_driver *driver, char *name, void *driverdata)
card
->
new_ncci
=
controllercb_new_ncci
;
card
->
free_ncci
=
controllercb_free_ncci
;
for
(
pp
=
&
driver
->
controller
;
*
pp
;
pp
=
&
(
*
pp
)
->
next
)
;
card
->
next
=
0
;
*
pp
=
card
;
list_add_tail
(
&
card
->
driver_list
,
&
driver
->
contr_head
);
driver
->
ncontroller
++
;
sprintf
(
card
->
procfn
,
"capi/controllers/%d"
,
card
->
cnr
);
card
->
procent
=
create_proc_entry
(
card
->
procfn
,
0
,
0
);
...
...
@@ -1013,20 +1029,16 @@ drivercb_attach_ctr(struct capi_driver *driver, char *name, void *driverdata)
static
int
drivercb_detach_ctr
(
struct
capi_ctr
*
card
)
{
struct
capi_driver
*
driver
=
card
->
driver
;
struct
capi_ctr
**
pp
;
if
(
card
->
cardstate
==
CARD_FREE
)
return
0
;
if
(
card
->
cardstate
!=
CARD_DETECTED
)
controllercb_reseted
(
card
);
for
(
pp
=
&
driver
->
controller
;
*
pp
;
pp
=
&
(
*
pp
)
->
next
)
{
if
(
*
pp
==
card
)
{
*
pp
=
card
->
next
;
list_del
(
&
card
->
driver_list
);
driver
->
ncontroller
--
;
ncards
--
;
break
;
}
}
if
(
card
->
procent
)
{
remove_proc_entry
(
card
->
procfn
,
0
);
card
->
procent
=
0
;
...
...
@@ -1066,13 +1078,9 @@ static struct capi_driver_interface di = {
struct
capi_driver_interface
*
attach_capi_driver
(
struct
capi_driver
*
driver
)
{
struct
capi_driver
**
pp
;
MOD_INC_USE_COUNT
;
INIT_LIST_HEAD
(
&
driver
->
contr_head
);
spin_lock
(
&
drivers_lock
);
for
(
pp
=
&
drivers
;
*
pp
;
pp
=
&
(
*
pp
)
->
next
)
;
driver
->
next
=
0
;
*
pp
=
driver
;
list_add_tail
(
&
driver
->
driver_list
,
&
drivers
);
spin_unlock
(
&
drivers_lock
);
printk
(
KERN_NOTICE
"kcapi: driver %s attached
\n
"
,
driver
->
name
);
sprintf
(
driver
->
procfn
,
"capi/drivers/%s"
,
driver
->
name
);
...
...
@@ -1092,21 +1100,15 @@ struct capi_driver_interface *attach_capi_driver(struct capi_driver *driver)
void
detach_capi_driver
(
struct
capi_driver
*
driver
)
{
struct
capi_driver
**
pp
;
spin_lock
(
&
drivers_lock
);
for
(
pp
=
&
drivers
;
*
pp
&&
*
pp
!=
driver
;
pp
=
&
(
*
pp
)
->
next
)
;
if
(
*
pp
)
{
*
pp
=
(
*
pp
)
->
next
;
printk
(
KERN_NOTICE
"kcapi: driver %s detached
\n
"
,
driver
->
name
);
}
else
{
printk
(
KERN_ERR
"kcapi: driver %s double detach ?
\n
"
,
driver
->
name
);
}
list_del
(
&
driver
->
driver_list
);
spin_unlock
(
&
drivers_lock
);
printk
(
KERN_NOTICE
"kcapi: driver %s detached
\n
"
,
driver
->
name
);
if
(
driver
->
procent
)
{
remove_proc_entry
(
driver
->
procfn
,
0
);
driver
->
procent
=
0
;
}
MOD_DEC_USE_COUNT
;
}
/* ------------------------------------------------------------- */
...
...
@@ -1310,11 +1312,16 @@ static u16 capi_get_profile(u32 contr, struct capi_profile *profp)
static
struct
capi_driver
*
find_driver
(
char
*
name
)
{
struct
list_head
*
l
;
struct
capi_driver
*
dp
;
spin_lock
(
&
drivers_lock
);
for
(
dp
=
drivers
;
dp
;
dp
=
dp
->
next
)
list_for_each
(
l
,
&
drivers
)
{
dp
=
list_entry
(
l
,
struct
capi_driver
,
driver_list
);
if
(
strcmp
(
dp
->
name
,
name
)
==
0
)
break
;
goto
found
;
}
dp
=
NULL
;
found:
spin_unlock
(
&
drivers_lock
);
return
dp
;
}
...
...
@@ -1611,22 +1618,10 @@ struct capi_interface avmb1_interface =
struct
capi_interface
*
attach_capi_interface
(
struct
capi_interface_user
*
userp
)
{
struct
capi_interface_user
*
p
;
MOD_INC_USE_COUNT
;
spin_lock
(
&
capi_users_lock
);
for
(
p
=
capi_users
;
p
;
p
=
p
->
next
)
{
if
(
p
==
userp
)
{
spin_unlock
(
&
capi_users_lock
);
printk
(
KERN_ERR
"kcapi: double attach from %s
\n
"
,
userp
->
name
);
MOD_DEC_USE_COUNT
;
return
0
;
}
}
userp
->
next
=
capi_users
;
capi_users
=
userp
;
spin_unlock
(
&
capi_users_lock
);
spin_lock
(
&
users_lock
);
list_add_tail
(
&
userp
->
user_list
,
&
users
);
spin_unlock
(
&
users_lock
);
printk
(
KERN_NOTICE
"kcapi: %s attached
\n
"
,
userp
->
name
);
return
&
avmb1_interface
;
...
...
@@ -1634,22 +1629,10 @@ struct capi_interface *attach_capi_interface(struct capi_interface_user *userp)
int
detach_capi_interface
(
struct
capi_interface_user
*
userp
)
{
struct
capi_interface_user
**
pp
;
spin_lock
(
&
capi_users_lock
);
for
(
pp
=
&
capi_users
;
*
pp
;
pp
=
&
(
*
pp
)
->
next
)
{
if
(
*
pp
==
userp
)
{
*
pp
=
userp
->
next
;
spin_unlock
(
&
capi_users_lock
);
userp
->
next
=
0
;
spin_lock
(
&
users_lock
);
list_del
(
&
userp
->
user_list
);
printk
(
KERN_NOTICE
"kcapi: %s detached
\n
"
,
userp
->
name
);
MOD_DEC_USE_COUNT
;
return
0
;
}
}
spin_unlock
(
&
capi_users_lock
);
printk
(
KERN_ERR
"kcapi: double detach from %s
\n
"
,
userp
->
name
);
return
-
1
;
}
/* ------------------------------------------------------------- */
...
...
drivers/isdn/hardware/avm/b1pcmcia.c
View file @
e9123b30
...
...
@@ -188,10 +188,12 @@ int b1pcmcia_addcard_m2(unsigned int port, unsigned irq)
int
b1pcmcia_delcard
(
unsigned
int
port
,
unsigned
irq
)
{
struct
list_head
*
l
;
struct
capi_ctr
*
ctrl
;
avmcard
*
card
;
for
(
ctrl
=
b1pcmcia_driver
.
controller
;
ctrl
;
ctrl
=
ctrl
->
next
)
{
list_for_each
(
l
,
&
b1pcmcia_driver
.
contr_head
)
{
ctrl
=
list_entry
(
l
,
struct
capi_ctr
,
driver_list
);
card
=
((
avmctrl_info
*
)(
ctrl
->
driverdata
))
->
card
;
if
(
card
->
port
==
port
&&
card
->
irq
==
irq
)
{
b1pcmcia_remove_ctr
(
ctrl
);
...
...
drivers/isdn/hardware/avm/t1isa.c
View file @
e9123b30
...
...
@@ -344,6 +344,7 @@ static void t1isa_remove_ctr(struct capi_ctr *ctrl)
static
int
t1isa_add_card
(
struct
capi_driver
*
driver
,
struct
capicardparams
*
p
)
{
struct
capi_ctr
*
ctrl
;
struct
list_head
*
l
;
avmctrl_info
*
cinfo
;
avmcard
*
card
;
int
retval
;
...
...
@@ -376,8 +377,11 @@ static int t1isa_add_card(struct capi_driver *driver, struct capicardparams *p)
retval
=
-
EINVAL
;
goto
err_free
;
}
for
(
ctrl
=
driver
->
controller
;
ctrl
;
ctrl
=
ctrl
->
next
)
{
avmcard
*
cardp
=
((
avmctrl_info
*
)(
ctrl
->
driverdata
))
->
card
;
list_for_each
(
l
,
&
driver
->
contr_head
)
{
avmcard
*
cardp
;
ctrl
=
list_entry
(
l
,
struct
capi_ctr
,
driver_list
);
cardp
=
((
avmctrl_info
*
)(
ctrl
->
driverdata
))
->
card
;
if
(
cardp
->
cardnr
==
card
->
cardnr
)
{
printk
(
KERN_WARNING
"%s: card with number %d already installed at 0x%x.
\n
"
,
driver
->
name
,
card
->
cardnr
,
cardp
->
port
);
...
...
include/linux/isdn/capilli.h
View file @
e9123b30
...
...
@@ -12,6 +12,8 @@
#ifndef __CAPILLI_H__
#define __CAPILLI_H__
#include <linux/list.h>
typedef
struct
capiloaddatapart
{
int
user
;
/* data in userspace ? */
int
len
;
...
...
@@ -34,7 +36,7 @@ typedef struct capicardparams {
struct
capi_driver
;
struct
capi_ctr
{
struct
capi_ctr
*
next
;
/* next ctr of same
driver */
struct
list_head
driver_list
;
/* contrs by
driver */
struct
capi_driver
*
driver
;
int
cnr
;
/* controller number */
char
name
[
32
];
/* name of controller */
...
...
@@ -99,8 +101,8 @@ struct capi_driver {
int
(
*
add_card
)(
struct
capi_driver
*
driver
,
capicardparams
*
data
);
/* intitialized by kcapi */
struct
capi_ctr
*
controller
;
/* list of controllers */
struct
capi_driver
*
nex
t
;
struct
list_head
contr_head
;
/* list of controllers */
struct
list_head
driver_lis
t
;
int
ncontroller
;
struct
proc_dir_entry
*
procent
;
char
procfn
[
128
];
...
...
include/linux/kernelcapi.h
View file @
e9123b30
...
...
@@ -10,6 +10,8 @@
#ifndef __KERNELCAPI_H__
#define __KERNELCAPI_H__
#include <linux/list.h>
#define CAPI_MAXAPPL 128
/* maximum number of applications */
#define CAPI_MAXCONTR 16
/* maximum number of controller */
#define CAPI_MAXDATAWINDOW 8
...
...
@@ -81,7 +83,7 @@ struct capi_interface_user {
char
name
[
20
];
void
(
*
callback
)
(
unsigned
int
cmd
,
__u32
contr
,
void
*
data
);
/* internal */
struct
capi_interface_user
*
nex
t
;
struct
list_head
user_lis
t
;
};
struct
capi_interface
*
attach_capi_interface
(
struct
capi_interface_user
*
);
...
...
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