提交 4db7589f 编写于 作者: M Marcel Holtmann

Bluetooth: Use wait_event_interruptible for virtual driver

The virtual driver still uses a home grown way of waiting for events and
so just replace it with wait_event_interruptible. And while at it remove
the useless access_ok() checks.
Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
上级 ac28494c
...@@ -179,41 +179,31 @@ static inline ssize_t vhci_put_user(struct vhci_data *data, ...@@ -179,41 +179,31 @@ static inline ssize_t vhci_put_user(struct vhci_data *data,
static ssize_t vhci_read(struct file *file, static ssize_t vhci_read(struct file *file,
char __user *buf, size_t count, loff_t *pos) char __user *buf, size_t count, loff_t *pos)
{ {
DECLARE_WAITQUEUE(wait, current);
struct vhci_data *data = file->private_data; struct vhci_data *data = file->private_data;
struct sk_buff *skb; struct sk_buff *skb;
ssize_t ret = 0; ssize_t ret = 0;
add_wait_queue(&data->read_wait, &wait);
while (count) { while (count) {
set_current_state(TASK_INTERRUPTIBLE);
skb = skb_dequeue(&data->readq); skb = skb_dequeue(&data->readq);
if (!skb) { if (skb) {
if (file->f_flags & O_NONBLOCK) { ret = vhci_put_user(data, skb, buf, count);
ret = -EAGAIN; if (ret < 0)
break; skb_queue_head(&data->readq, skb);
} else
kfree_skb(skb);
if (signal_pending(current)) { break;
ret = -ERESTARTSYS;
break;
}
schedule();
continue;
} }
if (access_ok(VERIFY_WRITE, buf, count)) if (file->f_flags & O_NONBLOCK) {
ret = vhci_put_user(data, skb, buf, count); ret = -EAGAIN;
else break;
ret = -EFAULT; }
kfree_skb(skb); ret = wait_event_interruptible(data->read_wait,
break; !skb_queue_empty(&data->readq));
if (ret < 0)
break;
} }
set_current_state(TASK_RUNNING);
remove_wait_queue(&data->read_wait, &wait);
return ret; return ret;
} }
...@@ -223,9 +213,6 @@ static ssize_t vhci_write(struct file *file, ...@@ -223,9 +213,6 @@ static ssize_t vhci_write(struct file *file,
{ {
struct vhci_data *data = file->private_data; struct vhci_data *data = file->private_data;
if (!access_ok(VERIFY_READ, buf, count))
return -EFAULT;
return vhci_get_user(data, buf, count); return vhci_get_user(data, buf, count);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册