From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752235AbcFKSEL (ORCPT ); Sat, 11 Jun 2016 14:04:11 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:48798 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751328AbcFKSEH (ORCPT ); Sat, 11 Jun 2016 14:04:07 -0400 Subject: Re: [RFC PATCHv3] usb: USB Type-C Connector Class To: Oliver Neukum , Heikki Krogerus References: <1463661894-22820-1-git-send-email-heikki.krogerus@linux.intel.com> <1465569269-63856-1-git-send-email-heikki.krogerus@linux.intel.com> <1465628746.3339.3.camel@suse.com> Cc: Felipe Balbi , Greg KH , Pavel Machek , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org From: Guenter Roeck Message-ID: <575C5289.3020009@roeck-us.net> Date: Sat, 11 Jun 2016 11:03:53 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: <1465628746.3339.3.camel@suse.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated_sender: linux@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: linux@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: linux@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/11/2016 12:05 AM, Oliver Neukum wrote: > On Fri, 2016-06-10 at 17:34 +0300, Heikki Krogerus wrote: >> +static ssize_t >> +preferred_role_store(struct device *dev, struct device_attribute >> *attr, >> + const char *buf, size_t size) >> +{ >> + struct typec_port *port = to_typec_port(dev); >> + enum typec_role role; >> + int ret; >> + >> + mutex_lock(&port->lock); >> + >> + if (port->cap->type != TYPEC_PORT_DRP) { >> + dev_dbg(dev, "Try.SRC/SNK only supported with DRP >> ports\n"); >> + ret = -EOPNOTSUPP; >> + goto out; >> + } > > I think Try.SNK with an UFP should fail differently from > Try.SRC and vice versa. > I think the message should not even mention Try.src or Try.snk in the first place, since both are optional and really orthogonal to how the role is set (it can also be changed with pd messages). On top of that, the specification states that Try.{src/snk} are optional if there is no PD support, and NA if PD is supported (see table 4.10). Kind of interesting, and I wonder how this is supposed to be implemented in practice, since Try.{src/snk} runs before it is established that/if the partner supports PD. A better message would be something like "Setting preferred role only supported with DRP ports", and leave implementation details to the port driver. Guenter