Remove the execution flag from non-executables
[platform/core/connectivity/mtp-responder.git] / src / transport / mtp_usb_driver_ffs.c
old mode 100755 (executable)
new mode 100644 (file)
index 091daa8..4c3e844
@@ -33,6 +33,7 @@
 #include "mtp_thread.h"
 #include "mtp_transport.h"
 #include "mtp_event_handler.h"
+#include "mtp_init.h"
 #include <sys/prctl.h>
 #include <systemd/sd-daemon.h>
 
@@ -70,11 +71,13 @@ static void __handle_control_request(mtp_int32 request);
  * FUNCTIONS
  */
 
+/* LCOV_EXCL_START */
 static mtp_bool __io_init()
 {
        int ret;
 
        if (sd_listen_fds(0) >= 4) {
+               DBG("socket-activated");
                g_usb_ep0 = SD_LISTEN_FDS_START;
                g_usb_ep_in = SD_LISTEN_FDS_START + 1;
                g_usb_ep_out = SD_LISTEN_FDS_START + 2;
@@ -308,7 +311,7 @@ static int __setup(int ep0, struct usb_ctrlrequest *ctrl)
                DBG(__FILE__ "(%s):%d: USB_PTPREQUEST_%s",
                    __func__, __LINE__, requests[ctrl->bRequest-0x64]);
                if (wValue != 0 || wIndex != 0 || wLength != 6) {
-                       DBG("Invalid request parameters: wValue:%d wIndex:%d wLength:%d\n");
+                       DBG("Invalid request parameters: wValue:%hu wIndex:%hu wLength:%hu\n", wIndex, wValue, wLength);
                        rc = -EINVAL;
                        goto stall;
                }
@@ -350,7 +353,7 @@ stall:
 
        if (status != -1 || errno != EL2HLT) {
                ERR(__FILE__"(%s):%d:stall error\n",
-                   __func__, __LINE__, ctrl->bRequestType, ctrl->bRequest);
+                   __func__, __LINE__);
                rc = errno;
        }
        return rc;
@@ -428,6 +431,15 @@ static void *ffs_transport_thread_usb_control(void *arg)
                            event.u.setup.wLength);
                        __setup(g_usb_ep0, &event.u.setup);
                        break;
+               case FUNCTIONFS_ENABLE:
+                       DBG("ENABLE");
+                       _util_set_local_usb_status(MTP_PHONE_USB_CONNECTED);
+                       break;
+               case FUNCTIONFS_DISABLE:
+                       DBG("DISABLE");
+                       _util_set_local_usb_status(MTP_PHONE_USB_DISCONNECTED);
+                       _eh_send_event_req_to_eh_thread(EVENT_USB_REMOVED, 0, 0, NULL);
+                       break;
                }
        } while (status > 0);
 
@@ -463,6 +475,8 @@ static mtp_int32 __handle_usb_read_err(mtp_int32 err,
                                ERR("_transport_init_usb_device Fail");
                                continue;
                        }
+               } else if (err < 0 && errno == ESHUTDOWN) {
+                       DBG("ESHUTDOWN");
                } else {
                        ERR("Unknown error : %d, errno [%d] \n", err, errno);
                        break;
@@ -483,10 +497,11 @@ static void __clean_up_msg_queue(void *mq_id)
 {
        mtp_int32 len = 0;
        msgq_ptr_t pkt = { 0 };
-       msgq_id_t l_mqid = *(msgq_id_t *)mq_id;
+       msgq_id_t l_mqid;
 
        ret_if(mq_id == NULL);
 
+       l_mqid = *(msgq_id_t *)mq_id;
        _transport_set_control_event(PTP_EVENTCODE_CANCELTRANSACTION);
        while (TRUE == _util_msgq_receive(l_mqid, (void *)&pkt,
                                          sizeof(msgq_ptr_t) - sizeof(long), 1, &len)) {
@@ -648,6 +663,7 @@ static mtp_uint32 ffs_transport_get_usb_packet_len(void)
 
        return MTP_MAX_PACKET_SIZE_SEND_HS;
 }
+/* LCOV_EXCL_STOP */
 
 
 const mtp_usb_driver_t mtp_usb_driver_ffs = {