Skip to content

Commit

Permalink
usb: typec: Hide the port_type attribute when it's not supported
Browse files Browse the repository at this point in the history
The port_type attribute is special. It is meant to allow
changing the capability of the port in runtime. It is purely
Linux kernel specific feature, i.e. the feature is not
described in any of the USB specifications.

Because of the special nature of this attribute, handling it
differently compared to the other writable attributes, and
hiding it when the underlying port interface (or just the
driver) does not support the feature.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20200211112531.86510-3-heikki.krogerus@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Heikki Krogerus authored and Greg Kroah-Hartman committed Feb 12, 2020
1 parent b747038 commit 7932306
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/usb/typec/class.c
Original file line number Diff line number Diff line change
Expand Up @@ -1350,8 +1350,9 @@ static umode_t typec_attr_is_visible(struct kobject *kobj,
!port->ops || !port->ops->try_role)
return 0444;
} else if (attr == &dev_attr_port_type.attr) {
if (port->cap->type != TYPEC_PORT_DRP ||
!port->ops || !port->ops->port_type_set)
if (!port->ops || !port->ops->port_type_set)
return 0;
if (port->cap->type != TYPEC_PORT_DRP)
return 0444;
}

Expand Down

0 comments on commit 7932306

Please sign in to comment.