gadget: f_thor: Return proper error value for thor_init()
authorSeung-Woo Kim <sw0312.kim@samsung.com>
Fri, 24 Apr 2020 07:40:40 +0000 (16:40 +0900)
committerJaehoon Chung <jh80.chung@samsung.com>
Mon, 28 Oct 2024 11:27:56 +0000 (20:27 +0900)
After the commit 17679aed622b ("usb: thor: add screen support"),
caller of thor_init() expects general error value to check
interrupt by Ctrl-C but thor_init() returns wrong error value -1
for Ctrl-C termination during rx or wrong protocol response.
Return proper error for the cases.

Change-Id: I8a637918930673bad953a88e26c79b8e64580bc8
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
drivers/usb/gadget/f_thor.c

index 4f765ba3c54d90f07d5765361c1ab7670541541a..5b4b8b310660bc69194c6e2ad6f309579e63ceff 100644 (file)
@@ -711,6 +711,7 @@ int thor_init(struct udevice *udc)
 {
        struct thor_dev *dev = thor_func->dev;
        int power_key_cnt = 0;
+       int ret;
 
 #ifdef CONFIG_TIZEN
 #ifdef CONFIG_LCD      /* TODO : Need to enable LCD*/
@@ -742,9 +743,10 @@ int thor_init(struct udevice *udc)
 #endif
        thor_set_dma(thor_rx_data_buf, strlen("THOR"));
        /* detect the download request from Host PC */
-       if (thor_rx_data(udc) < 0) {
+       ret = thor_rx_data(udc);
+       if (ret < 0) {
                printf("%s: Data not received!\n", __func__);
-               return -1;
+               return ret;
        }
 
        if (!strncmp((char *)thor_rx_data_buf, "THOR", strlen("THOR"))) {
@@ -755,7 +757,7 @@ int thor_init(struct udevice *udc)
                thor_tx_data(udc, thor_tx_data_buf, strlen("ROHT"));
        } else {
                puts("Wrong reply information\n");
-               return -1;
+               return -EPROTO;
        }
 
        return 0;