Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 28389
b: refs/heads/master
c: 943e1b4
h: refs/heads/master
i:
  28387: 1bead7f
v: v3
  • Loading branch information
Franck Bui-Huu authored and Greg Kroah-Hartman committed Jun 21, 2006
1 parent e48cc97 commit 61297c4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 79 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: b059c81af7a1759a911cfc20ce8a4bf47c435830
refs/heads/master: 943e1b4d60dc7acfabe2ebad31189bcb3b853688
95 changes: 17 additions & 78 deletions trunk/drivers/usb/gadget/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,82 +51,10 @@
#include "gadget_chips.h"


/* Wait Cond */

#define __wait_cond_interruptible(wq, condition, lock, flags, ret) \
do { \
wait_queue_t __wait; \
init_waitqueue_entry(&__wait, current); \
\
add_wait_queue(&wq, &__wait); \
for (;;) { \
set_current_state(TASK_INTERRUPTIBLE); \
if (condition) \
break; \
if (!signal_pending(current)) { \
spin_unlock_irqrestore(lock, flags); \
schedule(); \
spin_lock_irqsave(lock, flags); \
continue; \
} \
ret = -ERESTARTSYS; \
break; \
} \
current->state = TASK_RUNNING; \
remove_wait_queue(&wq, &__wait); \
} while (0)

#define wait_cond_interruptible(wq, condition, lock, flags) \
({ \
int __ret = 0; \
if (!(condition)) \
__wait_cond_interruptible(wq, condition, lock, flags, \
__ret); \
__ret; \
})

#define __wait_cond_interruptible_timeout(wq, condition, lock, flags, \
timeout, ret) \
do { \
signed long __timeout = timeout; \
wait_queue_t __wait; \
init_waitqueue_entry(&__wait, current); \
\
add_wait_queue(&wq, &__wait); \
for (;;) { \
set_current_state(TASK_INTERRUPTIBLE); \
if (__timeout == 0) \
break; \
if (condition) \
break; \
if (!signal_pending(current)) { \
spin_unlock_irqrestore(lock, flags); \
__timeout = schedule_timeout(__timeout); \
spin_lock_irqsave(lock, flags); \
continue; \
} \
ret = -ERESTARTSYS; \
break; \
} \
current->state = TASK_RUNNING; \
remove_wait_queue(&wq, &__wait); \
} while (0)

#define wait_cond_interruptible_timeout(wq, condition, lock, flags, \
timeout) \
({ \
int __ret = 0; \
if (!(condition)) \
__wait_cond_interruptible_timeout(wq, condition, lock, \
flags, timeout, __ret); \
__ret; \
})


/* Defines */

#define GS_VERSION_STR "v2.0"
#define GS_VERSION_NUM 0x0200
#define GS_VERSION_STR "v2.1"
#define GS_VERSION_NUM 0x0201

#define GS_LONG_NAME "Gadget Serial"
#define GS_SHORT_NAME "g_serial"
Expand Down Expand Up @@ -843,6 +771,18 @@ static int gs_open(struct tty_struct *tty, struct file *file)
/*
* gs_close
*/

#define GS_WRITE_FINISHED_EVENT_SAFELY(p) \
({ \
unsigned long flags; \
int cond; \
\
spin_lock_irqsave(&(p)->port_lock, flags); \
cond = !(p)->port_dev || !gs_buf_data_avail((p)->port_write_buf); \
spin_unlock_irqrestore(&(p)->port_lock, flags); \
cond; \
})

static void gs_close(struct tty_struct *tty, struct file *file)
{
unsigned long flags;
Expand Down Expand Up @@ -888,10 +828,9 @@ static void gs_close(struct tty_struct *tty, struct file *file)
/* at most GS_CLOSE_TIMEOUT seconds */
if (gs_buf_data_avail(port->port_write_buf) > 0) {
spin_unlock_irqrestore(&port->port_lock, flags);
wait_cond_interruptible_timeout(port->port_write_wait,
port->port_dev == NULL
|| gs_buf_data_avail(port->port_write_buf) == 0,
&port->port_lock, flags, GS_CLOSE_TIMEOUT * HZ);
wait_event_interruptible_timeout(port->port_write_wait,
GS_WRITE_FINISHED_EVENT_SAFELY(port),
GS_CLOSE_TIMEOUT * HZ);
spin_lock_irqsave(&port->port_lock, flags);
}

Expand Down

0 comments on commit 61297c4

Please sign in to comment.