diff options
author | Takashi Iwai <tiwai@suse.de> | 2013-06-07 14:34:37 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2013-06-07 14:36:59 +0200 |
commit | 6bace726387332b2d4d9dd563e8b0fc82dbce952 (patch) | |
tree | 79cb32abd2122084f6ecdd85d385ef345474056e | |
parent | fa09c12e5195e3085ec6a94e8fde4417e5c67318 (diff) | |
download | hda-emu-6bace726387332b2d4d9dd563e8b0fc82dbce952.tar.gz |
Allow rescheduling of work in the work itself
For example, the jack polling code needs the self rescheduling.
Also, flush the pending work at the end of each command, also for
the wrong / help command. So you can execute the pending work by
pressing RETURN on the prompt.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | hda-ctlsh.c | 4 | ||||
-rw-r--r-- | include/linux/workqueue.h | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/hda-ctlsh.c b/hda-ctlsh.c index 64f225e..e6417a7 100644 --- a/hda-ctlsh.c +++ b/hda-ctlsh.c @@ -982,8 +982,7 @@ int cmd_loop(FILE *fp) p = gettoken(&buf); if (!p) { usage(NULL); - free(line); - continue; + goto next; } tbl = cmd_match(p); @@ -994,6 +993,7 @@ int cmd_loop(FILE *fp) else tbl->handler(buf); + next: flush_scheduled_work(); free(line); } diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h index 4feb9aa..1a8834e 100644 --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h @@ -34,10 +34,10 @@ static inline bool cancel_work_sync(struct work_struct *x) { return 0; } static inline bool cancel_delayed_work_sync(struct delayed_work *x) { return 0; } static inline void flush_scheduled_work(void) { - if (__work_pending) { - __work_pending->work.func(&__work_pending->work); - __work_pending = NULL; - } + struct delayed_work *tmp_work = __work_pending; + __work_pending = NULL; + if (tmp_work) + tmp_work->work.func(&tmp_work->work); } #define create_workqueue(x) (struct workqueue_struct *)1 /* dummy */ |