Commit 7c5bbb2e authored by Dmitry Torokhov's avatar Dmitry Torokhov

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: default avatarWanlong Gao <gaowanlong@cn.fujitsu.com>
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent ba538cd2
...@@ -38,11 +38,11 @@ struct serio_raw { ...@@ -38,11 +38,11 @@ struct serio_raw {
struct serio *serio; struct serio *serio;
struct miscdevice dev; struct miscdevice dev;
wait_queue_head_t wait; wait_queue_head_t wait;
struct list_head list; struct list_head client_list;
struct list_head node; struct list_head node;
}; };
struct serio_raw_list { struct serio_raw_client {
struct fasync_struct *fasync; struct fasync_struct *fasync;
struct serio_raw *serio_raw; struct serio_raw *serio_raw;
struct list_head node; struct list_head node;
...@@ -58,9 +58,9 @@ static unsigned int serio_raw_no; ...@@ -58,9 +58,9 @@ static unsigned int serio_raw_no;
static int serio_raw_fasync(int fd, struct file *file, int on) static int serio_raw_fasync(int fd, struct file *file, int on)
{ {
struct serio_raw_list *list = file->private_data; struct serio_raw_client *client = file->private_data;
return fasync_helper(fd, file, on, &list->fasync); return fasync_helper(fd, file, on, &client->fasync);
} }
static struct serio_raw *serio_raw_locate(int minor) static struct serio_raw *serio_raw_locate(int minor)
...@@ -78,8 +78,8 @@ static struct serio_raw *serio_raw_locate(int minor) ...@@ -78,8 +78,8 @@ static struct serio_raw *serio_raw_locate(int minor)
static int serio_raw_open(struct inode *inode, struct file *file) static int serio_raw_open(struct inode *inode, struct file *file)
{ {
struct serio_raw *serio_raw; struct serio_raw *serio_raw;
struct serio_raw_list *list; struct serio_raw_client *client;
int retval = 0; int retval;
retval = mutex_lock_interruptible(&serio_raw_mutex); retval = mutex_lock_interruptible(&serio_raw_mutex);
if (retval) if (retval)
...@@ -96,17 +96,17 @@ static int serio_raw_open(struct inode *inode, struct file *file) ...@@ -96,17 +96,17 @@ static int serio_raw_open(struct inode *inode, struct file *file)
goto out; goto out;
} }
list = kzalloc(sizeof(struct serio_raw_list), GFP_KERNEL); client = kzalloc(sizeof(struct serio_raw_client), GFP_KERNEL);
if (!list) { if (!client) {
retval = -ENOMEM; retval = -ENOMEM;
goto out; goto out;
} }
list->serio_raw = serio_raw; client->serio_raw = serio_raw;
file->private_data = list; file->private_data = client;
kref_get(&serio_raw->kref); kref_get(&serio_raw->kref);
list_add_tail(&list->node, &serio_raw->list); list_add_tail(&client->node, &serio_raw->client_list);
out: out:
mutex_unlock(&serio_raw_mutex); mutex_unlock(&serio_raw_mutex);
...@@ -125,8 +125,8 @@ static void serio_raw_cleanup(struct kref *kref) ...@@ -125,8 +125,8 @@ static void serio_raw_cleanup(struct kref *kref)
static int serio_raw_release(struct inode *inode, struct file *file) static int serio_raw_release(struct inode *inode, struct file *file)
{ {
struct serio_raw_list *list = file->private_data; struct serio_raw_client *client = file->private_data;
struct serio_raw *serio_raw = list->serio_raw; struct serio_raw *serio_raw = client->serio_raw;
mutex_lock(&serio_raw_mutex); mutex_lock(&serio_raw_mutex);
...@@ -156,8 +156,8 @@ static int serio_raw_fetch_byte(struct serio_raw *serio_raw, char *c) ...@@ -156,8 +156,8 @@ static int serio_raw_fetch_byte(struct serio_raw *serio_raw, char *c)
static ssize_t serio_raw_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) static ssize_t serio_raw_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
{ {
struct serio_raw_list *list = file->private_data; struct serio_raw_client *client = file->private_data;
struct serio_raw *serio_raw = list->serio_raw; struct serio_raw *serio_raw = client->serio_raw;
char uninitialized_var(c); char uninitialized_var(c);
ssize_t retval = 0; ssize_t retval = 0;
...@@ -167,8 +167,9 @@ static ssize_t serio_raw_read(struct file *file, char __user *buffer, size_t cou ...@@ -167,8 +167,9 @@ static ssize_t serio_raw_read(struct file *file, char __user *buffer, size_t cou
if (serio_raw->head == serio_raw->tail && (file->f_flags & O_NONBLOCK)) if (serio_raw->head == serio_raw->tail && (file->f_flags & O_NONBLOCK))
return -EAGAIN; return -EAGAIN;
retval = wait_event_interruptible(list->serio_raw->wait, retval = wait_event_interruptible(serio_raw->wait,
serio_raw->head != serio_raw->tail || !serio_raw->serio); serio_raw->head != serio_raw->tail ||
!serio_raw->serio);
if (retval) if (retval)
return retval; return retval;
...@@ -186,7 +187,8 @@ static ssize_t serio_raw_read(struct file *file, char __user *buffer, size_t cou ...@@ -186,7 +187,8 @@ static ssize_t serio_raw_read(struct file *file, char __user *buffer, size_t cou
static ssize_t serio_raw_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) static ssize_t serio_raw_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
{ {
struct serio_raw_list *list = file->private_data; struct serio_raw_client *client = file->private_data;
struct serio_raw *serio_raw = client->serio_raw;
ssize_t written = 0; ssize_t written = 0;
int retval; int retval;
unsigned char c; unsigned char c;
...@@ -195,7 +197,7 @@ static ssize_t serio_raw_write(struct file *file, const char __user *buffer, siz ...@@ -195,7 +197,7 @@ static ssize_t serio_raw_write(struct file *file, const char __user *buffer, siz
if (retval) if (retval)
return retval; return retval;
if (!list->serio_raw->serio) { if (!serio_raw->serio) {
retval = -ENODEV; retval = -ENODEV;
goto out; goto out;
} }
...@@ -208,7 +210,7 @@ static ssize_t serio_raw_write(struct file *file, const char __user *buffer, siz ...@@ -208,7 +210,7 @@ static ssize_t serio_raw_write(struct file *file, const char __user *buffer, siz
retval = -EFAULT; retval = -EFAULT;
goto out; goto out;
} }
if (serio_write(list->serio_raw->serio, c)) { if (serio_write(serio_raw->serio, c)) {
retval = -EIO; retval = -EIO;
goto out; goto out;
} }
...@@ -222,11 +224,12 @@ static ssize_t serio_raw_write(struct file *file, const char __user *buffer, siz ...@@ -222,11 +224,12 @@ static ssize_t serio_raw_write(struct file *file, const char __user *buffer, siz
static unsigned int serio_raw_poll(struct file *file, poll_table *wait) static unsigned int serio_raw_poll(struct file *file, poll_table *wait)
{ {
struct serio_raw_list *list = file->private_data; struct serio_raw_client *client = file->private_data;
struct serio_raw *serio_raw = client->serio_raw;
poll_wait(file, &list->serio_raw->wait, wait); poll_wait(file, &serio_raw->wait, wait);
if (list->serio_raw->head != list->serio_raw->tail) if (serio_raw->head != serio_raw->tail)
return POLLIN | POLLRDNORM; return POLLIN | POLLRDNORM;
return 0; return 0;
...@@ -252,16 +255,16 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data, ...@@ -252,16 +255,16 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
unsigned int dfl) unsigned int dfl)
{ {
struct serio_raw *serio_raw = serio_get_drvdata(serio); struct serio_raw *serio_raw = serio_get_drvdata(serio);
struct serio_raw_list *list; struct serio_raw_client *client;
unsigned int head = serio_raw->head; unsigned int head = serio_raw->head;
/* we are holding serio->lock here so we are prootected */ /* we are holding serio->lock here so we are protected */
serio_raw->queue[head] = data; serio_raw->queue[head] = data;
head = (head + 1) % SERIO_RAW_QUEUE_LEN; head = (head + 1) % SERIO_RAW_QUEUE_LEN;
if (likely(head != serio_raw->tail)) { if (likely(head != serio_raw->tail)) {
serio_raw->head = head; serio_raw->head = head;
list_for_each_entry(list, &serio_raw->list, node) list_for_each_entry(client, &serio_raw->client_list, node)
kill_fasync(&list->fasync, SIGIO, POLL_IN); kill_fasync(&client->fasync, SIGIO, POLL_IN);
wake_up_interruptible(&serio_raw->wait); wake_up_interruptible(&serio_raw->wait);
} }
...@@ -283,7 +286,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv) ...@@ -283,7 +286,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
snprintf(serio_raw->name, sizeof(serio_raw->name), "serio_raw%d", serio_raw_no++); snprintf(serio_raw->name, sizeof(serio_raw->name), "serio_raw%d", serio_raw_no++);
kref_init(&serio_raw->kref); kref_init(&serio_raw->kref);
serio_raw->serio = serio; serio_raw->serio = serio;
INIT_LIST_HEAD(&serio_raw->list); INIT_LIST_HEAD(&serio_raw->client_list);
init_waitqueue_head(&serio_raw->wait); init_waitqueue_head(&serio_raw->wait);
serio_set_drvdata(serio, serio_raw); serio_set_drvdata(serio, serio_raw);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment