usb: chipidea: add loop timeout for hw_ep_set_halt()
Subsystems (2)
PATCH 1/1 usb: chipidea: add loop timeout for hw_ep_set_halt()
If ctrl EP priming is failed (very rare case in standard linux), hw_ep_set_halt goes infinite loop. 50 was enough for zynq7000.
Signed-off-by Jeaho Hwang <[email protected]>
--- drivers/usb/chipidea/udc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/usb/chipidea/udc.c +6 -2
@@ -210,6 +210,9 @@ static int hw_ep_prime(struct ci_hdrc *ci, int num, int dir, int is_ctrl)return 0 ; } +/*will it be enough?*/ +#define HW_EP_SET_HALT_COUNT_MAX 100 +/** * hw_ep_set_halt: configures ep halt & resets data toggle after clear (execute * without interruption)
@@ -222,6 +225,7 @@ static int hw_ep_prime(struct ci_hdrc *ci, int num, int dir, int is_ctrl)*/ static int hw_ep_set_halt (struct ci_hdrc *ci,int num,int dir,int value) { +int count =HW_EP_SET_HALT_COUNT_MAX ;if (value !=0 && value !=1 )return -EINVAL ;
@@ -233,9 +237,9 @@ static int hw_ep_set_halt(struct ci_hdrc *ci, int num, int dir, int value)/* data toggle - reserved for EP0 but it's in ESS */ hw_write (ci, reg, mask_xs|mask_xr, value ? mask_xs : mask_xr); - }while (value !=hw_ep_get_halt (ci, num, dir)); + }while (value !=hw_ep_get_halt (ci, num, dir) && --count >0 ); -return 0 ; +return count ?0 : -EAGAIN ; }/**
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerQuoted 13 lines · Jeaho Hwang
If ctrl EP priming is failed (very rare case in standard linux),
hw_ep_set_haltgoes infinite loop. 50 was enough for zynq7000.Signed-off-by Jeaho Hwang <[email protected]>--- drivers/usb/chipidea/udc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/usb/chipidea/udc.c +0
-0
drivers/usb/chipidea/udc.c static int hw_ep_prime(struct ci_hdrc *ci, int num, int dir, int is_ctrl) · line 213
Quoted 4 lines
drivers/usb/chipidea/udc.c +1
-0@@ -210,6 +210,9 @@ static int hw_ep_prime(struct ci_hdrc *ci, int num, int dir, int is_ctrl)return 0 ; } +/*will it be enough?*/
Please use ' ' characters in your comments.
And can you answer this, please do not add a question in a comment, be sure about this.
drivers/usb/chipidea/udc.c static int hw_ep_prime(struct ci_hdrc *ci, int num, int dir, int is_ctrl) · line 229
Quoted 11 lines
drivers/usb/chipidea/udc.c +3
-0+#define HW_EP_SET_HALT_COUNT_MAX 100 +/** * hw_ep_set_halt: configures ep halt & resets data toggle after clear (execute * without interruption) @@ -222,6 +225,7 @@ static int hw_ep_prime(struct ci_hdrc *ci, int num, int dir, int is_ctrl)*/ static int hw_ep_set_halt (struct ci_hdrc *ci,int num,int dir,int value) { +int count =HW_EP_SET_HALT_COUNT_MAX ;if (value !=0 && value !=1 )
Please use checkpatch.pl when submitting patches :(