From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753460AbcEYNMk (ORCPT ); Wed, 25 May 2016 09:12:40 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:56167 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750812AbcEYNMj (ORCPT ); Wed, 25 May 2016 09:12:39 -0400 Subject: Re: [RFC PATCHv2] usb: USB Type-C Connector Class To: Heikki Krogerus References: <1463661894-22820-1-git-send-email-heikki.krogerus@linux.intel.com> <57445A31.9060304@roeck-us.net> <20160525113058.GC27570@kuha.fi.intel.com> Cc: Greg KH , Mathias Nyman , Felipe Balbi , Oliver Neukum , Rajaram R , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org From: Guenter Roeck Message-ID: <5745A4A2.9060502@roeck-us.net> Date: Wed, 25 May 2016 06:12:02 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <20160525113058.GC27570@kuha.fi.intel.com> Content-Type: text/plain; charset=windows-1252; 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 05/25/2016 04:30 AM, Heikki Krogerus wrote: > Hi, > > On Tue, May 24, 2016 at 06:42:09AM -0700, Guenter Roeck wrote: >>> +struct typec_capability { >>> + enum typec_data_role role; >>> + unsigned int usb_pd:1; >>> + struct typec_altmode *alt_modes; >>> + unsigned int audio_accessory:1; >>> + unsigned int debug_accessory:1; >>> + >>> + int (*fix_role)(struct typec_port *, >>> + enum typec_data_role); >>> + >>> + int (*dr_swap)(struct typec_port *); >>> + int (*pr_swap)(struct typec_port *); >>> + int (*vconn_swap)(struct typec_port *); >>> + >> >> The function parameter in those calls is all but useless to the caller. >> It needs to store the typec_port returned from typec_register(), create a >> list of ports, and then search through this list each time one of the >> functions is called. This is quite expensive for no good reason. >> >> Previously, with typec_port exported, the called code could use the stored >> caps pointer to map to its internal data structures. This is no longer >> possible. > > True, the API now is in practice broken. > >> I think it would be useful to provide a better means for the called function >> to identify its context. Maybe provide a pointer to the private data in >> the registration function and use it as parameter in the callback functions ? > > Sounds reasonable. > I'll send a follow-up patch hopefully later today which fixes all the problems I have found so far. Guenter