Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: chipidea: otg: set host_request_flag for gadget

Set host_request_flag if the current peripheral wants to take host role
via changing a_bus_req or b_bus_req by user application.

Acked-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>

authored by

Li Jun and committed by
Felipe Balbi
2dfb46be c5348b62

+12 -1
+12 -1
drivers/usb/chipidea/otg_fsm.c
··· 66 66 return count; 67 67 } 68 68 ci->fsm.a_bus_req = 1; 69 + if (ci->fsm.otg->state == OTG_STATE_A_PERIPHERAL) { 70 + ci->gadget.host_request_flag = 1; 71 + mutex_unlock(&ci->fsm.lock); 72 + return count; 73 + } 69 74 } 70 75 71 76 ci_otg_queue_work(ci); ··· 149 144 mutex_lock(&ci->fsm.lock); 150 145 if (buf[0] == '0') 151 146 ci->fsm.b_bus_req = 0; 152 - else if (buf[0] == '1') 147 + else if (buf[0] == '1') { 153 148 ci->fsm.b_bus_req = 1; 149 + if (ci->fsm.otg->state == OTG_STATE_B_PERIPHERAL) { 150 + ci->gadget.host_request_flag = 1; 151 + mutex_unlock(&ci->fsm.lock); 152 + return count; 153 + } 154 + } 154 155 155 156 ci_otg_queue_work(ci); 156 157 mutex_unlock(&ci->fsm.lock);