From: INSUN PYO Date: Fri, 27 Nov 2020 10:06:00 +0000 (+0900) Subject: usb: change usb initialization - skip usb hal operation when usb is disconnected. X-Git-Tag: accepted/tizen/unified/20201202.124927^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F20%2F248520%2F5;p=platform%2Fcore%2Fsystem%2Fdeviced.git usb: change usb initialization - skip usb hal operation when usb is disconnected. If USB is initialized without a USB connection, only initialize the internal usb state and skip usb hal operation. To support sdb over BT, sdbd.service should start automatically at boot time. If usb cable is not connected, usb hal stops sdbd.service when initializing usb. Change-Id: I936d0a62b5d3a0e8229ff02760e1a6d23081a003 --- diff --git a/src/usb/usb.c b/src/usb/usb.c index 407edde..f85bba3 100644 --- a/src/usb/usb.c +++ b/src/usb/usb.c @@ -386,7 +386,7 @@ int usb_change_mode(unsigned int new_mode, bool change_debug_mode) static int usb_state_changed(const char *index, int new_status) { int ret = -1; - static int old_status = -1; + static int old_status = -1; /* -1: Uninitialized, 0: disconnected, 1: connected */ /* For debugging. Do not move the location. */ _I("USB state is changed by extcon from (%d) to (%d).", old_status, new_status); @@ -400,7 +400,21 @@ static int usb_state_changed(const char *index, int new_status) break; case USB_DISCONNECTED: - ret = usb_disconnected(); + if (old_status == -1) { + /* only initialize the internal data state and skip usb hal operation. */ + _I("USB is initialized without USB connection"); + + /* From usb_disconnected() */ + usb_state_set_connection(USB_DISCONNECTED); + send_usb_state_changed_event(VCONFKEY_SYSMAN_USB_DISCONNECTED); + + /* From usb_disable() */ + (void)usb_state_set_current_mode(USB_FUNCTION_NONE); + change_usb_state_notification_handler(USB_FUNCTION_NONE); + + ret = 0; + } else + ret = usb_disconnected(); break; default: