Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp759132ybg; Wed, 23 Oct 2019 05:34:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJnxmfaVetfeQrEb+xKZ9dOGVZo4WfZWfyepNCsvl7Kk++z6IrCotu2D/PgZsR0H2V7/+d X-Received: by 2002:aa7:d304:: with SMTP id p4mr36894007edq.224.1571834049646; Wed, 23 Oct 2019 05:34:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571834049; cv=none; d=google.com; s=arc-20160816; b=j3O5yZ+2w2mQzqH3ZOLPcqHK1b3QWu5xePh6wck7OdeC9xRlCLqikf3KT+AnX2GCtz cKOV6/Y5Szk0XQpW+80kUqZfhNAMIYeYYznNhc9riM3JSJpaDT9anHUT9t+palsZjnys Q9IGO/1cqwbzdJjkvIL3GCz0r3A/VPj8XID2H5DkwEdJDTJ50I4M7OLpptb2o7FCGRm5 hA1e/kk0yy2l0Wzm3q10d3YXUaGX3gENehXbsF+4qPxQ0/vnCvmxEMu6J8bOHjEB4x2Z NfN6+G4iC5VGIy92KEz1qIlMIKCSWAUUjNkuY9WvvO9sxR6DgCfgkmqdwMOOr55Qx/SP FAoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=gDSky1ews0jldkusSMxFAo0UMl61LxeBki28VxffG0M=; b=P9XusDLW8HAQa4Jiwg3dZ7waGAXJJeE9+yCZlJfeoPwNOAJAgz9oBtZo6FxpekLPpT lbLJtEEm5JGVqn3RPj6c5pvBczTh5fkyldaWZ54ZzdDOZvYuxeTPifrzRoSY3ToIekTk toKFkDtz1eWvNgulX/jlBbM8tv6ULO4f9VyVCldM5y/W0GcBMuXFsD+V6QfN7TNR/qe/ n3UnFXRq91CfyK834QvrKmHmmCjreHwsT4evdBaOGKc1Od3CJ13SKLmF1MCkZB1rlmbM jUvysXr258y1YfyXdzUUXHA0xvPUKjpC/I9Nyi/65JWRESofnmLYHYNnx7zk6MAz4UUe wKSw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k12si9906011ede.181.2019.10.23.05.33.45; Wed, 23 Oct 2019 05:34:09 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390315AbfJWIc0 (ORCPT + 99 others); Wed, 23 Oct 2019 04:32:26 -0400 Received: from mga02.intel.com ([134.134.136.20]:4257 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390020AbfJWIc0 (ORCPT ); Wed, 23 Oct 2019 04:32:26 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Oct 2019 01:32:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,220,1569308400"; d="scan'208";a="209874161" Received: from kuha.fi.intel.com ([10.237.72.53]) by fmsmga001.fm.intel.com with SMTP; 23 Oct 2019 01:32:22 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Wed, 23 Oct 2019 11:32:21 +0300 Date: Wed, 23 Oct 2019 11:32:21 +0300 From: Heikki Krogerus To: Puma Hsu , Guenter Roeck 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 Subject: Re: [PATCH V2] usb: typec: Add sysfs node to show connector orientation Message-ID: <20191023083221.GB8828@kuha.fi.intel.com> References: <20191022085924.92783-1-pumahsu@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191022085924.92783-1-pumahsu@google.com> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +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? > 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, -- heikki