linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: pumahsu <pumahsu@google.com>
To: heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org
Cc: badhri@google.com, kyletso@google.com, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, pumahsu <pumahsu@google.com>
Subject: [PATCH] usb: typec: Add sysfs node to show cc orientation
Date: Wed, 16 Oct 2019 11:43:14 +0800	[thread overview]
Message-ID: <20191016034314.231363-1-pumahsu@google.com> (raw)

Export the Type-C cc orientation so that user space can
get this information.

Signed-off-by: pumahsu <pumahsu@google.com>
---
 Documentation/ABI/testing/sysfs-class-typec |  7 +++++++
 drivers/usb/typec/class.c                   | 11 +++++++++++
 2 files changed, 18 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-class-typec b/Documentation/ABI/testing/sysfs-class-typec
index d7647b258c3c..419f952c991d 100644
--- a/Documentation/ABI/testing/sysfs-class-typec
+++ b/Documentation/ABI/testing/sysfs-class-typec
@@ -108,6 +108,13 @@ Contact:	Heikki Krogerus <heikki.krogerus@linux.intel.com>
 Description:
 		Revision number of the supported USB Type-C specification.
 
+What:		/sys/class/typec/<port>/cc_orientation
+Date:		September 2019
+Contact:	Puma Hsu <pumahsu@google.com>
+Description:
+		Indicates which cc orientation is active now, or 0 when
+		nothing is connected.
+
 
 USB Type-C partner devices (eg. /sys/class/typec/port0-partner/)
 
diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index 7d8805d9bf37..00edae63da8e 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -1238,6 +1238,16 @@ static ssize_t usb_power_delivery_revision_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(usb_power_delivery_revision);
 
+static ssize_t cc_orientation_show(struct device *dev,
+						struct device_attribute *attr,
+						char *buf)
+{
+	struct typec_port *p = to_typec_port(dev);
+
+	return sprintf(buf, "%d\n", typec_get_orientation(p));
+}
+static DEVICE_ATTR_RO(cc_orientation);
+
 static struct attribute *typec_attrs[] = {
 	&dev_attr_data_role.attr,
 	&dev_attr_power_operation_mode.attr,
@@ -1248,6 +1258,7 @@ static struct attribute *typec_attrs[] = {
 	&dev_attr_usb_typec_revision.attr,
 	&dev_attr_vconn_source.attr,
 	&dev_attr_port_type.attr,
+	&dev_attr_cc_orientation.attr,
 	NULL,
 };
 ATTRIBUTE_GROUPS(typec);
-- 
2.23.0.700.g56cf767bdb-goog


             reply	other threads:[~2019-10-16  3:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-16  3:43 pumahsu [this message]
2019-10-16  3:47 ` [PATCH] usb: typec: Add sysfs node to show cc orientation Randy Dunlap
2019-10-16  8:59   ` Puma Hsu
2019-10-16  9:18 ` Greg KH
2019-10-16 12:58 ` Heikki Krogerus
2019-10-16 13:09   ` Heikki Krogerus
2019-10-22  8:57     ` Puma Hsu

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=20191016034314.231363-1-pumahsu@google.com \
    --to=pumahsu@google.com \
    --cc=badhri@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=kyletso@google.com \
    --cc=linux-kernel@vger.kernel.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).