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: Jack Pham <jackp@codeaurora.org>
This commit is contained in:
parent
563b2f7a6b
commit
fd0ff67425
1 changed files with 8 additions and 1 deletions
|
@ -1417,6 +1417,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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2656,11 +2657,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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue