linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org
Subject: [PATCH 2/6] usb: typec: Hide the port_type attribute when it's not supported
Date: Tue, 11 Feb 2020 14:25:27 +0300	[thread overview]
Message-ID: <20200211112531.86510-3-heikki.krogerus@linux.intel.com> (raw)
In-Reply-To: <20200211112531.86510-1-heikki.krogerus@linux.intel.com>

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>
---
 drivers/usb/typec/class.c | 5 +++--
 1 file 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;
 	}
 
-- 
2.25.0


  parent reply	other threads:[~2020-02-11 11:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-11 11:25 [PATCH 0/6] typec changes Heikki Krogerus
2020-02-11 11:25 ` [PATCHv2 1/6] usb: typec: Make the attributes read-only when writing is not possible Heikki Krogerus
2020-02-11 11:25 ` Heikki Krogerus [this message]
2020-02-11 11:25 ` [PATCH 3/6] usb: typec: Allow power role swapping even without USB PD Heikki Krogerus
2020-02-11 11:25 ` [PATCH 4/6] usb: typec: Fix the description of struct typec_capability Heikki Krogerus
2020-02-11 11:25 ` [PATCH 5/6] usb: typec: altmode: Remove the notification chain Heikki Krogerus
2020-02-11 11:25 ` [PATCH 6/6] usb: typec: mux: Drop support for device name matching Heikki Krogerus
2020-02-11 12:25 ` [PATCH 0/6] typec changes Greg Kroah-Hartman
2020-02-11 12:30   ` Heikki Krogerus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200211112531.86510-3-heikki.krogerus@linux.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).