summaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>2020-02-11 14:25:27 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-02-12 10:51:21 -0800
commit7932306a754a541f60b71b3551eb423f82d385cb (patch)
tree839a28abc4d50f6fcd68dc659eb0f28ebd71763a /drivers/usb
parentb747038d9d14a2ca9e6f139a8584507d5aed8634 (diff)
downloadlinux-7932306a754a541f60b71b3551eb423f82d385cb.tar.bz2
usb: typec: Hide the port_type attribute when it's not supported
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>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/typec/class.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index a451ae181fe9..7fed6855ad59 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -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;
}