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);
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: