From patchwork Mon Jun 11 11:08:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heikki Krogerus X-Patchwork-Id: 10457561 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 950B6602C8 for ; Mon, 11 Jun 2018 11:09:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88CC427E63 for ; Mon, 11 Jun 2018 11:09:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C9422837E; Mon, 11 Jun 2018 11:09:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97B4428329 for ; Mon, 11 Jun 2018 11:08:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932263AbeFKLIx (ORCPT ); Mon, 11 Jun 2018 07:08:53 -0400 Received: from mga11.intel.com ([192.55.52.93]:19033 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932652AbeFKLIw (ORCPT ); Mon, 11 Jun 2018 07:08:52 -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 fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jun 2018 04:08:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,501,1520924400"; d="scan'208";a="63056313" Received: from kuha.fi.intel.com ([10.237.72.189]) by fmsmga001.fm.intel.com with SMTP; 11 Jun 2018 04:08:47 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Mon, 11 Jun 2018 14:08:47 +0300 Date: Mon, 11 Jun 2018 14:08:47 +0300 From: Heikki Krogerus To: Li Jun Cc: robh+dt@kernel.org, gregkh@linuxfoundation.org, linux@roeck-us.net, cw00.choi@samsung.com, a.hajda@samsung.com, shufan_lee@richtek.com, peter.chen@nxp.com, garsilva@embeddedor.com, gsomlo@gmail.com, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-imx@nxp.com Subject: Re: [PATCH v6 05/15] usb: typec: add API to get typec basic port power and data config Message-ID: <20180611110847.GG17155@kuha.fi.intel.com> References: <1527475967-15201-1-git-send-email-jun.li@nxp.com> <1527475967-15201-6-git-send-email-jun.li@nxp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1527475967-15201-6-git-send-email-jun.li@nxp.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Jun, On Mon, May 28, 2018 at 10:52:37AM +0800, Li Jun wrote: > This patch adds 3 APIs to get the typec port power and data type, > and preferred power role by its name string. > > Signed-off-by: Li Jun > --- > drivers/usb/typec/class.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++ > include/linux/usb/typec.h | 3 +++ > 2 files changed, 53 insertions(+) > > diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c > index 53df10d..4c7d18c 100644 > --- a/drivers/usb/typec/class.c > +++ b/drivers/usb/typec/class.c > @@ -802,6 +802,12 @@ static const char * const typec_port_types[] = { > [TYPEC_PORT_DRP] = "dual", > }; > > +static const char * const typec_data_caps[] = { > + [TYPEC_PORT_DFP] = "host", > + [TYPEC_PORT_UFP] = "device", > + [TYPEC_PORT_DRD] = "dual", > +}; Since I guess you need to fix this patch in any case, could you rename that to "typec_port_data_roles". And while at it, how about using this as an opportunity to rename typec_port_types to typec_port_power_roles? So this just a suggestion, no need to actually change it :-) : Thanks, diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index abbd33939109..97f7eb0e9879 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -918,12 +918,18 @@ static const char * const typec_data_roles[] = { [TYPEC_HOST] = "host", }; -static const char * const typec_port_types[] = { +static const char * const typec_port_power_roles[] = { [TYPEC_PORT_SRC] = "source", [TYPEC_PORT_SNK] = "sink", [TYPEC_PORT_DRP] = "dual", }; +static const char * const typec_port_data_roles[] = { + [TYPEC_PORT_DFP] = "host", + [TYPEC_PORT_UFP] = "device", + [TYPEC_PORT_DRD] = "dual", +}; + static const char * const typec_port_types_drp[] = { [TYPEC_PORT_SRC] = "dual [source] sink", [TYPEC_PORT_SNK] = "dual source [sink]", @@ -1054,7 +1060,7 @@ static ssize_t power_role_store(struct device *dev, mutex_lock(&port->port_type_lock); if (port->port_type != TYPEC_PORT_DRP) { dev_dbg(dev, "port type fixed at \"%s\"", - typec_port_types[port->port_type]); + typec_port_power_roles[port->port_type]); ret = -EOPNOTSUPP; goto unlock_and_ret; } @@ -1095,7 +1101,7 @@ port_type_store(struct device *dev, struct device_attribute *attr, return -EOPNOTSUPP; } - ret = sysfs_match_string(typec_port_types, buf); + ret = sysfs_match_string(typec_port_power_roles, buf); if (ret < 0) return ret; @@ -1129,7 +1135,7 @@ port_type_show(struct device *dev, struct device_attribute *attr, return sprintf(buf, "%s\n", typec_port_types_drp[port->port_type]); - return sprintf(buf, "[%s]\n", typec_port_types[port->cap->type]); + return sprintf(buf, "[%s]\n", typec_port_power_roles[port->cap->type]); } static DEVICE_ATTR_RW(port_type);