aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2011-10-10 21:30:14 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2011-10-10 21:34:52 -0400
commit7c5bbb2eb7ad047b53c205b1f500bae7b0a88c06 (patch)
treedf68c3d449b3e94d7b2c3268317c987ed429e578
parentba538cd2a83f3556448759283d2330a603005afe (diff)
Input: serio_raw - rename serio_raw_list to serio_raw_client
'serio_raw_list' and 'list' names do not accurately represent their objects and are extremely confusing when reading the code. Let's use better suited names. Reviewed-by: Wanlong Gao <gaowanlong@cn.fujitsu.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
-rw-r--r--drivers/input/serio/serio_raw.c75
1 files changed, 39 insertions, 36 deletions
diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
index ef3a69c304d3..6b57ee37efeb 100644
--- a/drivers/input/serio/serio_raw.c
+++ b/drivers/input/serio/serio_raw.c
@@ -38,11 +38,11 @@ struct serio_raw {
38 struct serio *serio; 38 struct serio *serio;
39 struct miscdevice dev; 39 struct miscdevice dev;
40 wait_queue_head_t wait; 40 wait_queue_head_t wait;
41 struct list_head list; 41 struct list_head client_list;
42 struct list_head node; 42 struct list_head node;
43}; 43};
44 44
45struct serio_raw_list { 45struct serio_raw_client {
46 struct fasync_struct *fasync; 46 struct fasync_struct *fasync;
47 struct serio_raw *serio_raw; 47 struct serio_raw *serio_raw;
48 struct list_head node; 48 struct list_head node;
@@ -58,9 +58,9 @@ static unsigned int serio_raw_no;
58 58
59static int serio_raw_fasync(int fd, struct file *file, int on) 59static int serio_raw_fasync(int fd, struct file *file, int on)
60{ 60{
61 struct serio_raw_list *list = file->private_data; 61 struct serio_raw_client *client = file->private_data;
62 62
63 return fasync_helper(fd, file, on, &list->fasync); 63 return fasync_helper(fd, file, on, &client->fasync);
64} 64}
65 65
66static struct serio_raw *serio_raw_locate(int minor) 66static struct serio_raw *serio_raw_locate(int minor)
@@ -78,8 +78,8 @@ static struct serio_raw *serio_raw_locate(int minor)
78static int serio_raw_open(struct inode *inode, struct file *file) 78static int serio_raw_open(struct inode *inode, struct file *file)
79{ 79{
80 struct serio_raw *serio_raw; 80 struct serio_raw *serio_raw;
81 struct serio_raw_list *list; 81 struct serio_raw_client *client;
82 int retval = 0; 82 int retval;
83 83
84 retval = mutex_lock_interruptible(&serio_raw_mutex); 84 retval = mutex_lock_interruptible(&serio_raw_mutex);
85 if (retval) 85 if (retval)
@@ -96,17 +96,17 @@ static int serio_raw_open(struct inode *inode, struct file *file)
96 goto out; 96 goto out;
97 } 97 }
98 98
99 list = kzalloc(sizeof(struct serio_raw_list), GFP_KERNEL); 99 client = kzalloc(sizeof(struct serio_raw_client), GFP_KERNEL);
100 if (!list) { 100 if (!client) {
101 retval = -ENOMEM; 101 retval = -ENOMEM;
102 goto out; 102 goto out;
103 } 103 }
104 104
105 list->serio_raw = serio_raw; 105 client->serio_raw = serio_raw;
106 file->private_data = list; 106 file->private_data = client;
107 107
108 kref_get(&serio_raw->kref); 108 kref_get(&serio_raw->kref);
109 list_add_tail(&list->node, &serio_raw->list); 109 list_add_tail(&client->node, &serio_raw->client_list);
110 110
111out: 111out:
112 mutex_unlock(&serio_raw_mutex); 112 mutex_unlock(&serio_raw_mutex);
@@ -125,8 +125,8 @@ static void serio_raw_cleanup(struct kref *kref)
125 125
126static int serio_raw_release(struct inode *inode, struct file *file) 126static int serio_raw_release(struct inode *inode, struct file *file)
127{ 127{
128 struct serio_raw_list *list = file->private_data; 128 struct serio_raw_client *client = file->private_data;
129 struct serio_raw *serio_raw = list->serio_raw; 129 struct serio_raw *serio_raw = client->serio_raw;
130 130
131 mutex_lock(&serio_raw_mutex); 131 mutex_lock(&serio_raw_mutex);
132 132
@@ -156,8 +156,8 @@ static int serio_raw_fetch_byte(struct serio_raw *serio_raw, char *c)
156 156
157static ssize_t serio_raw_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) 157static ssize_t serio_raw_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
158{ 158{
159 struct serio_raw_list *list = file->private_data; 159 struct serio_raw_client *client = file->private_data;
160 struct serio_raw *serio_raw = list->serio_raw; 160 struct serio_raw *serio_raw = client->serio_raw;
161 char uninitialized_var(c); 161 char uninitialized_var(c);
162 ssize_t retval = 0; 162 ssize_t retval = 0;
163 163
@@ -167,8 +167,9 @@ static ssize_t serio_raw_read(struct file *file, char __user *buffer, size_t cou
167 if (serio_raw->head == serio_raw->tail && (file->f_flags & O_NONBLOCK)) 167 if (serio_raw->head == serio_raw->tail && (file->f_flags & O_NONBLOCK))
168 return -EAGAIN; 168 return -EAGAIN;
169 169
170 retval = wait_event_interruptible(list->serio_raw->wait, 170 retval = wait_event_interruptible(serio_raw->wait,
171 serio_raw->head != serio_raw->tail || !serio_raw->serio); 171 serio_raw->head != serio_raw->tail ||
172 !serio_raw->serio);
172 if (retval) 173 if (retval)
173 return retval; 174 return retval;
174 175
@@ -186,7 +187,8 @@ static ssize_t serio_raw_read(struct file *file, char __user *buffer, size_t cou
186 187
187static ssize_t serio_raw_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) 188static ssize_t serio_raw_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
188{ 189{
189 struct serio_raw_list *list = file->private_data; 190 struct serio_raw_client *client = file->private_data;
191 struct serio_raw *serio_raw = client->serio_raw;
190 ssize_t written = 0; 192 ssize_t written = 0;
191 int retval; 193 int retval;
192 unsigned char c; 194 unsigned char c;
@@ -195,7 +197,7 @@ static ssize_t serio_raw_write(struct file *file, const char __user *buffer, siz
195 if (retval) 197 if (retval)
196 return retval; 198 return retval;
197 199
198 if (!list->serio_raw->serio) { 200 if (!serio_raw->serio) {
199 retval = -ENODEV; 201 retval = -ENODEV;
200 goto out; 202 goto out;
201 } 203 }
@@ -208,7 +210,7 @@ static ssize_t serio_raw_write(struct file *file, const char __user *buffer, siz
208 retval = -EFAULT; 210 retval = -EFAULT;
209 goto out; 211 goto out;
210 } 212 }
211 if (serio_write(list->serio_raw->serio, c)) { 213 if (serio_write(serio_raw->serio, c)) {
212 retval = -EIO; 214 retval = -EIO;
213 goto out; 215 goto out;
214 } 216 }
@@ -222,25 +224,26 @@ out:
222 224
223static unsigned int serio_raw_poll(struct file *file, poll_table *wait) 225static unsigned int serio_raw_poll(struct file *file, poll_table *wait)
224{ 226{
225 struct serio_raw_list *list = file->private_data; 227 struct serio_raw_client *client = file->private_data;
228 struct serio_raw *serio_raw = client->serio_raw;
226 229
227 poll_wait(file, &list->serio_raw->wait, wait); 230 poll_wait(file, &serio_raw->wait, wait);
228 231
229 if (list->serio_raw->head != list->serio_raw->tail) 232 if (serio_raw->head != serio_raw->tail)
230 return POLLIN | POLLRDNORM; 233 return POLLIN | POLLRDNORM;
231 234
232 return 0; 235 return 0;
233} 236}
234 237
235static const struct file_operations serio_raw_fops = { 238static const struct file_operations serio_raw_fops = {
236 .owner = THIS_MODULE, 239 .owner = THIS_MODULE,
237 .open = serio_raw_open, 240 .open = serio_raw_open,
238 .release = serio_raw_release, 241 .release = serio_raw_release,
239 .read = serio_raw_read, 242 .read = serio_raw_read,
240 .write = serio_raw_write, 243 .write = serio_raw_write,
241 .poll = serio_raw_poll, 244 .poll = serio_raw_poll,
242 .fasync = serio_raw_fasync, 245 .fasync = serio_raw_fasync,
243 .llseek = noop_llseek, 246 .llseek = noop_llseek,
244}; 247};
245 248
246 249
@@ -252,16 +255,16 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
252 unsigned int dfl) 255 unsigned int dfl)
253{ 256{
254 struct serio_raw *serio_raw = serio_get_drvdata(serio); 257 struct serio_raw *serio_raw = serio_get_drvdata(serio);
255 struct serio_raw_list *list; 258 struct serio_raw_client *client;
256 unsigned int head = serio_raw->head; 259 unsigned int head = serio_raw->head;
257 260
258 /* we are holding serio->lock here so we are prootected */ 261 /* we are holding serio->lock here so we are protected */
259 serio_raw->queue[head] = data; 262 serio_raw->queue[head] = data;
260 head = (head + 1) % SERIO_RAW_QUEUE_LEN; 263 head = (head + 1) % SERIO_RAW_QUEUE_LEN;
261 if (likely(head != serio_raw->tail)) { 264 if (likely(head != serio_raw->tail)) {
262 serio_raw->head = head; 265 serio_raw->head = head;
263 list_for_each_entry(list, &serio_raw->list, node) 266 list_for_each_entry(client, &serio_raw->client_list, node)
264 kill_fasync(&list->fasync, SIGIO, POLL_IN); 267 kill_fasync(&client->fasync, SIGIO, POLL_IN);
265 wake_up_interruptible(&serio_raw->wait); 268 wake_up_interruptible(&serio_raw->wait);
266 } 269 }
267 270
@@ -283,7 +286,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
283 snprintf(serio_raw->name, sizeof(serio_raw->name), "serio_raw%d", serio_raw_no++); 286 snprintf(serio_raw->name, sizeof(serio_raw->name), "serio_raw%d", serio_raw_no++);
284 kref_init(&serio_raw->kref); 287 kref_init(&serio_raw->kref);
285 serio_raw->serio = serio; 288 serio_raw->serio = serio;
286 INIT_LIST_HEAD(&serio_raw->list); 289 INIT_LIST_HEAD(&serio_raw->client_list);
287 init_waitqueue_head(&serio_raw->wait); 290 init_waitqueue_head(&serio_raw->wait);
288 291
289 serio_set_drvdata(serio, serio_raw); 292 serio_set_drvdata(serio, serio_raw);