No need for anything "harder" here (specifically no need for
irqsave...). Also, make the list removal the first operation of
capidev_free to avoid dumping half-released devices via /proc.
Signed-off-by: Jan Kiszka <jan.kiszka@web.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
/* -------- global variables ---------------------------------------- */
/* -------- global variables ---------------------------------------- */
-static DEFINE_RWLOCK(capidev_list_lock);
+static DEFINE_MUTEX(capidev_list_lock);
static LIST_HEAD(capidev_list);
#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
static LIST_HEAD(capidev_list);
#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
static struct capidev *capidev_alloc(void)
{
struct capidev *cdev;
static struct capidev *capidev_alloc(void)
{
struct capidev *cdev;
cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
if (!cdev)
cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
if (!cdev)
mutex_init(&cdev->ncci_list_mtx);
skb_queue_head_init(&cdev->recvqueue);
init_waitqueue_head(&cdev->recvwait);
mutex_init(&cdev->ncci_list_mtx);
skb_queue_head_init(&cdev->recvqueue);
init_waitqueue_head(&cdev->recvwait);
- write_lock_irqsave(&capidev_list_lock, flags);
+
+ mutex_lock(&capidev_list_lock);
list_add_tail(&cdev->list, &capidev_list);
list_add_tail(&cdev->list, &capidev_list);
- write_unlock_irqrestore(&capidev_list_lock, flags);
+ mutex_unlock(&capidev_list_lock);
+
return cdev;
}
static void capidev_free(struct capidev *cdev)
{
return cdev;
}
static void capidev_free(struct capidev *cdev)
{
+ mutex_lock(&capidev_list_lock);
+ list_del(&cdev->list);
+ mutex_unlock(&capidev_list_lock);
if (cdev->ap.applid) {
capi20_release(&cdev->ap);
if (cdev->ap.applid) {
capi20_release(&cdev->ap);
capincci_free(cdev, 0xffffffff);
mutex_unlock(&cdev->ncci_list_mtx);
capincci_free(cdev, 0xffffffff);
mutex_unlock(&cdev->ncci_list_mtx);
- write_lock_irqsave(&capidev_list_lock, flags);
- list_del(&cdev->list);
- write_unlock_irqrestore(&capidev_list_lock, flags);
struct capidev *cdev;
struct list_head *l;
struct capidev *cdev;
struct list_head *l;
- read_lock(&capidev_list_lock);
+ mutex_lock(&capidev_list_lock);
list_for_each(l, &capidev_list) {
cdev = list_entry(l, struct capidev, list);
seq_printf(m, "0 %d %lu %lu %lu %lu\n",
list_for_each(l, &capidev_list) {
cdev = list_entry(l, struct capidev, list);
seq_printf(m, "0 %d %lu %lu %lu %lu\n",
cdev->ap.nsentctlpkt,
cdev->ap.nsentdatapkt);
}
cdev->ap.nsentctlpkt,
cdev->ap.nsentdatapkt);
}
- read_unlock(&capidev_list_lock);
+ mutex_unlock(&capidev_list_lock);
struct capincci *np;
struct list_head *l;
struct capincci *np;
struct list_head *l;
- read_lock(&capidev_list_lock);
+ mutex_lock(&capidev_list_lock);
list_for_each(l, &capidev_list) {
cdev = list_entry(l, struct capidev, list);
for (np=cdev->nccis; np; np = np->next) {
list_for_each(l, &capidev_list) {
cdev = list_entry(l, struct capidev, list);
for (np=cdev->nccis; np; np = np->next) {
- read_unlock(&capidev_list_lock);
+ mutex_unlock(&capidev_list_lock);