aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/telephony/phonedev.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/telephony/phonedev.c')
-rw-r--r--drivers/telephony/phonedev.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/drivers/telephony/phonedev.c b/drivers/telephony/phonedev.c
index 3c987f49f6b4..7a6db1c5c8c5 100644
--- a/drivers/telephony/phonedev.c
+++ b/drivers/telephony/phonedev.c
@@ -29,6 +29,7 @@
29#include <linux/kmod.h> 29#include <linux/kmod.h>
30#include <linux/sem.h> 30#include <linux/sem.h>
31#include <linux/devfs_fs_kernel.h> 31#include <linux/devfs_fs_kernel.h>
32#include <linux/mutex.h>
32 33
33#define PHONE_NUM_DEVICES 256 34#define PHONE_NUM_DEVICES 256
34 35
@@ -37,7 +38,7 @@
37 */ 38 */
38 39
39static struct phone_device *phone_device[PHONE_NUM_DEVICES]; 40static struct phone_device *phone_device[PHONE_NUM_DEVICES];
40static DECLARE_MUTEX(phone_lock); 41static DEFINE_MUTEX(phone_lock);
41 42
42/* 43/*
43 * Open a phone device. 44 * Open a phone device.
@@ -53,14 +54,14 @@ static int phone_open(struct inode *inode, struct file *file)
53 if (minor >= PHONE_NUM_DEVICES) 54 if (minor >= PHONE_NUM_DEVICES)
54 return -ENODEV; 55 return -ENODEV;
55 56
56 down(&phone_lock); 57 mutex_lock(&phone_lock);
57 p = phone_device[minor]; 58 p = phone_device[minor];
58 if (p) 59 if (p)
59 new_fops = fops_get(p->f_op); 60 new_fops = fops_get(p->f_op);
60 if (!new_fops) { 61 if (!new_fops) {
61 up(&phone_lock); 62 mutex_unlock(&phone_lock);
62 request_module("char-major-%d-%d", PHONE_MAJOR, minor); 63 request_module("char-major-%d-%d", PHONE_MAJOR, minor);
63 down(&phone_lock); 64 mutex_lock(&phone_lock);
64 p = phone_device[minor]; 65 p = phone_device[minor];
65 if (p == NULL || (new_fops = fops_get(p->f_op)) == NULL) 66 if (p == NULL || (new_fops = fops_get(p->f_op)) == NULL)
66 { 67 {
@@ -78,7 +79,7 @@ static int phone_open(struct inode *inode, struct file *file)
78 } 79 }
79 fops_put(old_fops); 80 fops_put(old_fops);
80end: 81end:
81 up(&phone_lock); 82 mutex_unlock(&phone_lock);
82 return err; 83 return err;
83} 84}
84 85
@@ -100,18 +101,18 @@ int phone_register_device(struct phone_device *p, int unit)
100 end = unit + 1; /* enter the loop at least one time */ 101 end = unit + 1; /* enter the loop at least one time */
101 } 102 }
102 103
103 down(&phone_lock); 104 mutex_lock(&phone_lock);
104 for (i = base; i < end; i++) { 105 for (i = base; i < end; i++) {
105 if (phone_device[i] == NULL) { 106 if (phone_device[i] == NULL) {
106 phone_device[i] = p; 107 phone_device[i] = p;
107 p->minor = i; 108 p->minor = i;
108 devfs_mk_cdev(MKDEV(PHONE_MAJOR,i), 109 devfs_mk_cdev(MKDEV(PHONE_MAJOR,i),
109 S_IFCHR|S_IRUSR|S_IWUSR, "phone/%d", i); 110 S_IFCHR|S_IRUSR|S_IWUSR, "phone/%d", i);
110 up(&phone_lock); 111 mutex_unlock(&phone_lock);
111 return 0; 112 return 0;
112 } 113 }
113 } 114 }
114 up(&phone_lock); 115 mutex_unlock(&phone_lock);
115 return -ENFILE; 116 return -ENFILE;
116} 117}
117 118
@@ -121,12 +122,12 @@ int phone_register_device(struct phone_device *p, int unit)
121 122
122void phone_unregister_device(struct phone_device *pfd) 123void phone_unregister_device(struct phone_device *pfd)
123{ 124{
124 down(&phone_lock); 125 mutex_lock(&phone_lock);
125 if (phone_device[pfd->minor] != pfd) 126 if (phone_device[pfd->minor] != pfd)
126 panic("phone: bad unregister"); 127 panic("phone: bad unregister");
127 devfs_remove("phone/%d", pfd->minor); 128 devfs_remove("phone/%d", pfd->minor);
128 phone_device[pfd->minor] = NULL; 129 phone_device[pfd->minor] = NULL;
129 up(&phone_lock); 130 mutex_unlock(&phone_lock);
130} 131}
131 132
132 133