Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d8aa0fd5 authored by Jack Pham's avatar Jack Pham
Browse files

usb: pd: Avoid dual_role_instance_changed() if nothing changed



We call this notifier on the dual_role_usb class instance to
report any changes in state such as data role and power role.
But if we are already in explicit contract and return to either
PE_SRC_Ready or PE_SNK_Ready states, then that means the power
role has not changed, so there is no need to update the dual_role
instance. This will avoid a 2 second system wakeup timer which
will delay allowing the system to suspend.

Change-Id: I0ba6dc8903b7a010735be4e73e609e7aefa19d96
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent 2baec134
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -1499,6 +1499,9 @@ static void usbpd_set_state(struct usbpd *pd, enum usbpd_state next_state)
				!pd->in_explicit_contract)
			stop_usb_host(pd);

		if (!pd->in_explicit_contract)
			dual_role_instance_changed(pd->dual_role);

		pd->in_explicit_contract = true;

		if (pd->vdm_tx && !pd->sm_queued)
@@ -1512,7 +1515,6 @@ static void usbpd_set_state(struct usbpd *pd, enum usbpd_state next_state)

		kobject_uevent(&pd->dev.kobj, KOBJ_CHANGE);
		complete(&pd->is_ready);
		dual_role_instance_changed(pd->dual_role);
		break;

	case PE_PRS_SRC_SNK_TRANSITION_TO_OFF:
@@ -1687,6 +1689,9 @@ static void usbpd_set_state(struct usbpd *pd, enum usbpd_state next_state)
		break;

	case PE_SNK_READY:
		if (!pd->in_explicit_contract)
			dual_role_instance_changed(pd->dual_role);

		pd->in_explicit_contract = true;

		if (pd->vdm_tx)
@@ -1698,7 +1703,6 @@ static void usbpd_set_state(struct usbpd *pd, enum usbpd_state next_state)

		kobject_uevent(&pd->dev.kobj, KOBJ_CHANGE);
		complete(&pd->is_ready);
		dual_role_instance_changed(pd->dual_role);
		break;

	case PE_SNK_TRANSITION_TO_DEFAULT: