mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-23 11:36:09 +00:00
skypopen: OSS driver, added some code from /dev/zero to read(), and performances are better
This commit is contained in:
parent
4e95227f39
commit
7f81c3cc3c
@ -249,6 +249,7 @@ static ssize_t skypopen_read(struct file *filp, char __user *buf, size_t count,
|
|||||||
loff_t *f_pos)
|
loff_t *f_pos)
|
||||||
{
|
{
|
||||||
DEFINE_WAIT(wait);
|
DEFINE_WAIT(wait);
|
||||||
|
size_t written;
|
||||||
struct skypopen_dev *dev = filp->private_data;
|
struct skypopen_dev *dev = filp->private_data;
|
||||||
|
|
||||||
if(unload)
|
if(unload)
|
||||||
@ -273,8 +274,31 @@ static ssize_t skypopen_read(struct file *filp, char __user *buf, size_t count,
|
|||||||
prepare_to_wait(&dev->inq, &wait, TASK_INTERRUPTIBLE);
|
prepare_to_wait(&dev->inq, &wait, TASK_INTERRUPTIBLE);
|
||||||
schedule();
|
schedule();
|
||||||
finish_wait(&dev->inq, &wait);
|
finish_wait(&dev->inq, &wait);
|
||||||
return count;
|
|
||||||
|
|
||||||
|
if (!count)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!access_ok(VERIFY_WRITE, buf, count))
|
||||||
|
return -EFAULT;
|
||||||
|
|
||||||
|
written = 0;
|
||||||
|
while (count) {
|
||||||
|
unsigned long unwritten;
|
||||||
|
size_t chunk = count;
|
||||||
|
|
||||||
|
if (chunk > PAGE_SIZE)
|
||||||
|
chunk = PAGE_SIZE; /* Just for latency reasons */
|
||||||
|
unwritten = __clear_user(buf, chunk);
|
||||||
|
written += chunk - unwritten;
|
||||||
|
if (unwritten)
|
||||||
|
break;
|
||||||
|
if (signal_pending(current))
|
||||||
|
return written ? written : -ERESTARTSYS;
|
||||||
|
buf += chunk;
|
||||||
|
count -= chunk;
|
||||||
|
cond_resched();
|
||||||
|
}
|
||||||
|
return written ? written : -EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t skypopen_write(struct file *filp, const char __user *buf, size_t count,
|
static ssize_t skypopen_write(struct file *filp, const char __user *buf, size_t count,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user