With this CL the lower level drivers are reponsible to check and make sure that the role swap can be performed. This facilitates the lower level driver to attempt to perform role swap through initial connection process. Quoting from the Type-C specification release(page 24), role swaps are not limited to devices that only support PD. "Two independent set of mechanisms are defined to allow a USB Type-C DRP to functionally swap power and data roles. When USB PD is supported, power and data role swapping is performed as a subsequent step following the initial connection process. For non-PD implementations, power/data role swapping can optionally be dealt with as part of the initial connection process." Signed-off-by: Badhri Jagan Sridharan <Badhri@xxxxxxxxxx> --- Documentation/ABI/testing/sysfs-class-typec | 7 +++++-- drivers/usb/typec/typec.c | 10 ---------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-class-typec b/Documentation/ABI/testing/sysfs-class-typec index d4a3d23eb09c..ba4ca684adb2 100644 --- a/Documentation/ABI/testing/sysfs-class-typec +++ b/Documentation/ABI/testing/sysfs-class-typec @@ -20,13 +20,16 @@ Date: April 2017 Contact: Heikki Krogerus <heikki.krogerus@xxxxxxxxxxxxxxx> Description: The supported power roles. This attribute can be used to request - power role swap on the port when the port supports USB Power - Delivery. Swapping is supported as synchronous operation, so + power role swap. Swapping is supported as synchronous operation, so write(2) to the attribute will not return until the operation has finished. The attribute is notified about role changes so that poll(2) on the attribute wakes up. Change on the role will also generate uevent KOBJ_CHANGE. The current role is show in brackets, for example "[source] sink" when in source mode. + When both the port and the port-partner supports USB Power + Delivery, the PR_SWAP command is used to perform the role swap. + Otherwise, the port roles would be re-resolved by forcing + a disconnect and reconnect. Valid values: source, sink diff --git a/drivers/usb/typec/typec.c b/drivers/usb/typec/typec.c index 89e540bb7ff3..fd2d661665fa 100644 --- a/drivers/usb/typec/typec.c +++ b/drivers/usb/typec/typec.c @@ -887,21 +887,11 @@ static ssize_t power_role_store(struct device *dev, struct typec_port *port = to_typec_port(dev); int ret = size; - if (!port->cap->pd_revision) { - dev_dbg(dev, "USB Power Delivery not supported\n"); - return -EOPNOTSUPP; - } - if (!port->cap->pr_set) { dev_dbg(dev, "power role swapping not supported\n"); return -EOPNOTSUPP; } - if (port->pwr_opmode != TYPEC_PWR_MODE_PD) { - dev_dbg(dev, "partner unable to swap power role\n"); - return -EIO; - } - ret = sysfs_match_string(typec_roles, buf); if (ret < 0) return ret; -- 2.13.0.303.g4ebf302169-goog -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html