[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <57445A31.9060304@roeck-us.net>
Date: Tue, 24 May 2016 06:42:09 -0700
From: Guenter Roeck <linux@...ck-us.net>
To: Heikki Krogerus <heikki.krogerus@...ux.intel.com>
Cc: Greg KH <gregkh@...uxfoundation.org>,
Mathias Nyman <mathias.nyman@...ux.intel.com>,
Felipe Balbi <felipe.balbi@...ux.intel.com>,
Oliver Neukum <oneukum@...e.com>,
Rajaram R <rajaram.officemail@...il.com>,
Andy Shevchenko <andy.shevchenko@...il.com>,
linux-kernel@...r.kernel.org, linux-usb@...r.kernel.org
Subject: Re: [RFC PATCHv2] usb: USB Type-C Connector Class
On 05/19/2016 05:44 AM, Heikki Krogerus wrote:
> The purpose of this class is to provide unified interface for user
> space to get the status and basic information about USB Type-C
> Connectors in the system, control data role swapping, and when USB PD
> is available, also power role swapping and Alternate Modes.
>
> Signed-off-by: Heikki Krogerus <heikki.krogerus@...ux.intel.com>
> ---
> drivers/usb/Kconfig | 2 +
> drivers/usb/Makefile | 2 +
> drivers/usb/type-c/Kconfig | 7 +
> drivers/usb/type-c/Makefile | 1 +
> drivers/usb/type-c/typec.c | 957 ++++++++++++++++++++++++++++++++++++++++++++
> include/linux/usb/typec.h | 230 +++++++++++
> 6 files changed, 1199 insertions(+)
> create mode 100644 drivers/usb/type-c/Kconfig
> create mode 100644 drivers/usb/type-c/Makefile
> create mode 100644 drivers/usb/type-c/typec.c
> create mode 100644 include/linux/usb/typec.h
>
Hi,
> +/*
> + * struct typec_capability - USB Type-C Port Capabilities
> + * @role: DFP (Host-only), UFP (Device-only) or DRP (Dual Role)
> + * @usb_pd: USB Power Delivery support
> + * @alt_modes: Alternate Modes the connector supports (null terminated)
> + * @audio_accessory: Audio Accessory Adapter Mode support
> + * @debug_accessory: Debug Accessory Mode support
> + * @fix_role: Set a fixed data role for DRP port
> + * @dr_swap: Data Role Swap support
> + * @pr_swap: Power Role Swap support
> + * @vconn_swap: VCONN Swap support
> + * @activate_mode: Enter/exit given Alternate Mode
> + *
> + * Static capabilities of a single USB Type-C port.
> + */
> +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.
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 ?
Thanks,
Guenter
Powered by blists - more mailing lists