Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1285603ybg; Wed, 23 Oct 2019 13:18:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqyf/Mb2HuVP19jsorP0uDr48kN+8e4Sb1kjvD2srAlXDIiEv2ARpy2/7D8EXyOAfIUVloe8 X-Received: by 2002:a17:906:6094:: with SMTP id t20mr34802216ejj.316.1571861901351; Wed, 23 Oct 2019 13:18:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571861901; cv=none; d=google.com; s=arc-20160816; b=QZQpdmHPnR/+X7IjxcE17K5UiRl+UtOeD9KqXKErz/0s/4eW7lgB8Peoowtw2xpdk0 W9PHbUoYoYfSQkyw14eI7Qal171z18lOrBpbRg1VTJ4U5XMVf+7j6Gz3n15OeNg2q1AQ ALLw9k+4ytc8QkxA4GK2PddWMlR/xh2XD+4z5OA3g3aTV2pJPaZTFTZJXs9IOT8I1fFC j2j0F5IukOSsc7czL7z/gZK3wiMJJUjIcKTwCyOBlm/N40XHqtK4zgHL1V8jI7h9I+43 To43ME+Treyz5QLc0pWlPMvcxb2gq037jtHDxviLt0CkL7QZ6yL4kgUR4oZQraeZ4Hjh SGOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=bqtujpqNbAQZJihzkVcd83j8KH7ymy87CfXaLggRLzI=; b=Ri2kn4x/JSafDkgoMHpPNavnHD+TMA9w62vSXcLKG+4MHVPU2K4u3Joa03iqauMw4R xtTUOCkz85mdsvphJOe6odlbpXXCeUceRG68+bXIi5vAf3COJuhfVX9zW3Njv/1K+GaY hc83K0Z8WjDyTgc1UwWdxz5mAXOtXXhRhQ0esk2TAe0fZp2mVlKJc7Rn1QpPYXtftCRg qfi9QVc4p5xTqJlGxLkZ02+zrLfQnQM/8PUwSvCyKzbN2j5sLVb8D7RLpX+yCo3A1qIY b9QWvVbACoU66zF3ihYAOb4Ly8JPue1G2TsT+bRPes06xpzi32lV6Z1QNGZjZBA4VkMH kqsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=gv70QZPx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e7si13670104ejk.20.2019.10.23.13.17.56; Wed, 23 Oct 2019 13:18:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=gv70QZPx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406022AbfJWNoo (ORCPT + 99 others); Wed, 23 Oct 2019 09:44:44 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:40168 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390619AbfJWNon (ORCPT ); Wed, 23 Oct 2019 09:44:43 -0400 Received: by mail-pf1-f193.google.com with SMTP id x127so12974094pfb.7; Wed, 23 Oct 2019 06:44:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=bqtujpqNbAQZJihzkVcd83j8KH7ymy87CfXaLggRLzI=; b=gv70QZPxr2QwDImicOJ1btC3vgXVITVLotvnT607VxEd8XS3mo/bGtx97d/jSuVlbr dyknHxENLL/MOdE0rdHVwQVdcdbhcN3/Yi02vJHWZsVEyNMShMjGeH2gqeLtICIPKWvK qbVr+84wC5WFR7qEq6t998irZjaFIzwMFTSQWY8TYE3zrUYVfuami09BD7Y8xpGyOfvy b/rbasGj/axsSZt02719YmCyf0EqBJi+sx+ZeOzpRnkxnnX6J7CW2kamhYMCQQtifDkD jiZrVeHyyOEsCdBaboc2bfyys/BRD0UaTASvn/ktI4dc2JDrFsFqHg/cMfi/7sS7v84b HVwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=bqtujpqNbAQZJihzkVcd83j8KH7ymy87CfXaLggRLzI=; b=J96CzqDuln15H4a86c8VE+UayOxIipl9Dbw9P/jT5TmdLt4/WBjv1tlEpZZb3lamWN C2zrwPRHLkTHVwxbv31kZ/k1P7Qpc09GyAGOyuj4XjkwoPz303uHxWoEBmactzDJauDD 4PvJjp/0zDNczD/CPfSTs1mk3z/X4Z5y+LCCBZoprOZKxIMHUmD7ksIFfRWCq5BJVza1 5uO00ELokeRmw2yLCkzNmVVzhZX6tFbdu/Zy9SGtY9u+ITeaSSZIw020Lgn1n2gOGSk5 P3Lo5YL843OsubQhO1nf/Ns9sDsDqAC9ZUXpXuQNUwsgFP/QPNm6lGLtz8PTRTp7DOW+ mJaw== X-Gm-Message-State: APjAAAWiVq3K9gA6yTEtGJdLs9TRgQmJjEpTeVMfBRW5raHWuPUczwi8 GLhn06oeJyGS3B0NC7lhvjX+HYUz X-Received: by 2002:a63:7845:: with SMTP id t66mr9987694pgc.31.1571838282149; Wed, 23 Oct 2019 06:44:42 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id c9sm4026398pfb.114.2019.10.23.06.44.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Oct 2019 06:44:41 -0700 (PDT) Subject: Re: [PATCH V2] usb: typec: Add sysfs node to show connector orientation To: Heikki Krogerus , Puma Hsu Cc: gregkh@linuxfoundation.org, badhri@google.com, kyletso@google.com, albertccwang@google.com, rickyniu@google.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org References: <20191022085924.92783-1-pumahsu@google.com> <20191023083221.GB8828@kuha.fi.intel.com> From: Guenter Roeck Message-ID: <644d890b-86e8-f05a-cd4c-32937d971a45@roeck-us.net> Date: Wed, 23 Oct 2019 06:44:39 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20191023083221.GB8828@kuha.fi.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/23/19 1:32 AM, Heikki Krogerus wrote: > +Guenter > > On Tue, Oct 22, 2019 at 04:59:24PM +0800, Puma Hsu wrote: >> Export the Type-C connector orientation so that user space >> can get this information. >> >> Signed-off-by: Puma Hsu >> --- >> Documentation/ABI/testing/sysfs-class-typec | 11 +++++++++++ >> drivers/usb/typec/class.c | 18 ++++++++++++++++++ >> 2 files changed, 29 insertions(+) >> >> diff --git a/Documentation/ABI/testing/sysfs-class-typec b/Documentation/ABI/testing/sysfs-class-typec >> index d7647b258c3c..b22f71801671 100644 >> --- a/Documentation/ABI/testing/sysfs-class-typec >> +++ b/Documentation/ABI/testing/sysfs-class-typec >> @@ -108,6 +108,17 @@ Contact: Heikki Krogerus >> Description: >> Revision number of the supported USB Type-C specification. >> >> +What: /sys/class/typec//connector_orientation >> +Date: October 2019 >> +Contact: Puma Hsu >> +Description: >> + Indicates which typec connector orientation is configured now. >> + cc1 is defined as "normal" and cc2 is defined as "reversed". >> + >> + Valid value: >> + - unknown (nothing configured) > > "unknown" means we do not know the orientation. > >> + - normal (configured in cc1 side) >> + - reversed (configured in cc2 side) > > Guenter, do you think "connector_orientation" OK. I proposed it, but > I'm now wondering if something like "polarity" would be better? > Yes, or just "orientation". I don't see the value in the "connector_" prefix. I also wonder if "unknown" is really correct. Is it really unknown, or does it mean that the port is disconnected ? Guenter >> 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 94a3eda62add..911d06676aeb 100644 >> --- a/drivers/usb/typec/class.c >> +++ b/drivers/usb/typec/class.c >> @@ -1245,6 +1245,23 @@ static ssize_t usb_power_delivery_revision_show(struct device *dev, >> } >> static DEVICE_ATTR_RO(usb_power_delivery_revision); >> >> +static const char * const typec_connector_orientation[] = { >> + [TYPEC_ORIENTATION_NONE] = "unknown", >> + [TYPEC_ORIENTATION_NORMAL] = "normal", >> + [TYPEC_ORIENTATION_REVERSE] = "reversed", >> +}; >> + >> +static ssize_t connector_orientation_show(struct device *dev, >> + struct device_attribute *attr, >> + char *buf) >> +{ >> + struct typec_port *p = to_typec_port(dev); >> + >> + return sprintf(buf, "%s\n", >> + typec_connector_orientation[p->orientation]); >> +} >> +static DEVICE_ATTR_RO(connector_orientation); >> + >> static struct attribute *typec_attrs[] = { >> &dev_attr_data_role.attr, >> &dev_attr_power_operation_mode.attr, >> @@ -1255,6 +1272,7 @@ static struct attribute *typec_attrs[] = { >> &dev_attr_usb_typec_revision.attr, >> &dev_attr_vconn_source.attr, >> &dev_attr_port_type.attr, >> + &dev_attr_connector_orientation.attr, >> NULL, >> }; >> ATTRIBUTE_GROUPS(typec); > > thanks, >