Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 93293
b: refs/heads/master
c: 8a0f46b
h: refs/heads/master
i:
  93291: a8b59d8
v: v3
  • Loading branch information
matthias@kaehlcke.net authored and Greg Kroah-Hartman committed Apr 25, 2008
1 parent f43e35a commit 56bef28
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b994d7f70ae59b874843fa2bc9a28b17b41febd5
refs/heads/master: 8a0f46b92fcab6652b8e62c006d015d562302d08
18 changes: 9 additions & 9 deletions trunk/drivers/usb/misc/auerswald.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ typedef struct
auerbufctl_t bufctl; /* controls the buffer chain */
auerscon_t scontext; /* service context */
wait_queue_head_t readwait; /* for synchronous reading */
struct semaphore readmutex; /* protection against multiple reads */
struct mutex readmutex; /* protection against multiple reads */
pauerbuf_t readbuf; /* buffer held for partial reading */
unsigned int readoffset; /* current offset in readbuf */
unsigned int removed; /* is != 0 if device is removed */
Expand Down Expand Up @@ -1391,7 +1391,7 @@ static int auerchar_open (struct inode *inode, struct file *file)

/* Initialize device descriptor */
init_MUTEX( &ccp->mutex);
init_MUTEX( &ccp->readmutex);
mutex_init(&ccp->readmutex);
auerbuf_init (&ccp->bufctl);
ccp->scontext.id = AUH_UNASSIGNED;
ccp->scontext.dispatch = auerchar_ctrlread_dispatch;
Expand Down Expand Up @@ -1585,7 +1585,7 @@ static ssize_t auerchar_read (struct file *file, char __user *buf, size_t count,
}

/* only one reader per device allowed */
if (down_interruptible (&ccp->readmutex)) {
if (mutex_lock_interruptible(&ccp->readmutex)) {
up (&ccp->mutex);
return -ERESTARTSYS;
}
Expand All @@ -1603,7 +1603,7 @@ static ssize_t auerchar_read (struct file *file, char __user *buf, size_t count,
if (count) {
if (copy_to_user (buf, bp->bufp+ccp->readoffset, count)) {
dbg ("auerswald_read: copy_to_user failed");
up (&ccp->readmutex);
mutex_unlock(&ccp->readmutex);
up (&ccp->mutex);
return -EFAULT;
}
Expand All @@ -1618,7 +1618,7 @@ static ssize_t auerchar_read (struct file *file, char __user *buf, size_t count,
}
/* return with number of bytes read */
if (count) {
up (&ccp->readmutex);
mutex_unlock(&ccp->readmutex);
up (&ccp->mutex);
return count;
}
Expand Down Expand Up @@ -1655,7 +1655,7 @@ static ssize_t auerchar_read (struct file *file, char __user *buf, size_t count,
dbg ("No read buffer available, returning -EAGAIN");
set_current_state (TASK_RUNNING);
remove_wait_queue (&ccp->readwait, &wait);
up (&ccp->readmutex);
mutex_unlock(&ccp->readmutex);
up (&ccp->mutex);
return -EAGAIN; /* nonblocking, no data available */
}
Expand All @@ -1666,18 +1666,18 @@ static ssize_t auerchar_read (struct file *file, char __user *buf, size_t count,
remove_wait_queue (&ccp->readwait, &wait);
if (signal_pending (current)) {
/* waked up by a signal */
up (&ccp->readmutex);
mutex_unlock(&ccp->readmutex);
return -ERESTARTSYS;
}

/* Anything left to read? */
if ((ccp->scontext.id == AUH_UNASSIGNED) || ccp->removed) {
up (&ccp->readmutex);
mutex_unlock(&ccp->readmutex);
return -EIO;
}

if (down_interruptible (&ccp->mutex)) {
up (&ccp->readmutex);
mutex_unlock(&ccp->readmutex);
return -ERESTARTSYS;
}

Expand Down

0 comments on commit 56bef28

Please sign in to comment.