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

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

usb: pd: Determine dual_role writeable based on PD capability



Allowing 'data_role' and 'power_role' sysfs attributes to
be writeable implies that they can be changed independently.
This is only true if there is a PD-capable device attached,
otherwise the write permission should not be set.

Also make sure to call dual_role_instance_changed() at the
conclusion of initiating a DR swap in order to trigger the
is_writeable() callback to update the permissions. Note that
the PR swap case is already handled during the call to
usbpd_set_state(PE_{SRC,SNK}_READY).

Change-Id: I3f4bcaa8ae32af9a124e6f0967509c784e776f7d
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent 757ecb71
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -1426,6 +1426,7 @@ static void dr_swap(struct usbpd *pd)
	}

	pd_phy_update_roles(pd->current_dr, pd->current_pr);
	dual_role_instance_changed(pd->dual_role);
}


@@ -2665,11 +2666,17 @@ static int usbpd_dr_set_property(struct dual_role_phy_instance *dual_role,
static int usbpd_dr_prop_writeable(struct dual_role_phy_instance *dual_role,
		enum dual_role_property prop)
{
	struct usbpd *pd = dual_role_get_drvdata(dual_role);

	switch (prop) {
	case DUAL_ROLE_PROP_MODE:
		return 1;
	case DUAL_ROLE_PROP_DR:
	case DUAL_ROLE_PROP_PR:
		return 1;
		if (pd)
			return pd->current_state == PE_SNK_READY ||
				pd->current_state == PE_SRC_READY;
		break;
	default:
		break;
	}