[PATCH 10/12] usbgadget: ums: run gadget loop in a background coroutine if possible

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



With the new fancy poller yield support in place, we can let let the
loop yield in sleep_thread and naturally run in the background. Add this
and wrap it up inside an #ifdef, so the driver can still be used in
blocking mode for the architectures still missing out on poller yield
support.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 drivers/usb/gadget/f_mass_storage.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index 9c0076be26d1..c3e6eb933ce7 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -287,6 +287,18 @@ static struct usb_gadget_strings	fsg_stringtab = {
 
 /*-------------------------------------------------------------------------*/
 
+#ifdef CONFIG_POLLER_YIELD
+
+#include <linux/completion.h>
+#include <linux/kthread.h>
+
+static inline bool poll(void)
+{
+	return !ctrlc();
+}
+
+#else
+
 struct completion { int done; };
 
 #define init_completion(x) do { (x)->done = 0; } while (0)
@@ -331,6 +343,8 @@ static struct task_struct *kthread_run(int (*threadfn)(void *), void *arg,
 
 #define poll() thread_task->threadfn(thread_task->arg)
 
+#endif
+
 #define wait_event(queue, cond)	do { poll(); } while (!(cond))
 #define wake_up(...)		do {} while (0)
 
-- 
2.29.2


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux