{
int ret = -1;
static int old_status = -1; /* -1: Uninitialized, 0: disconnected, 1: connected */
+ static char old_index[NAME_MAX];
/* For debugging. Do not move the location. */
- _I("USB state is changed by extcon from (%d) to (%d).", old_status, new_status);
+ _I("USB state is changed by extcon \"%s\" from (%d) to (%d).", index ? index : "(NULL)", old_status, new_status);
+
+ if (old_index[0] != '\0' && index && strncmp(old_index, index, sizeof(old_index)) != 0) {
+ _I("USB state change ignored on extcon \"%s\"\n", index);
+ return 0;
+ }
if (old_status == new_status)
return 0;
switch (new_status) {
case USB_CONNECTED:
+ old_index[0] = '\0';
+ if (index) {
+ strncpy(old_index, index, sizeof(old_index) - 1);
+ old_index[sizeof(old_index) - 1] = '\0';
+ }
ret = usb_connected();
break;
if (old_status == -1) {
/* only initialize the internal data state and skip usb hal operation. */
_I("USB is initialized without USB connection");
+ old_index[0] = '\0';
/* From usb_disconnected() */
usb_state_set_connection(USB_DISCONNECTED);
change_usb_state_notification_handler(USB_GADGET_FUNC_NONE);
ret = 0;
- } else
+ } else {
+ old_index[0] = '\0';
ret = usb_disconnected();
+ }
break;
default: