[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YfkLn4UTjAea22wL@kroah.com>
Date: Tue, 1 Feb 2022 11:29:51 +0100
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: Samuel Holland <samuel@...lland.org>
Cc: Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Guenter Roeck <linux@...ck-us.net>,
Rob Herring <robh+dt@...nel.org>, devicetree@...r.kernel.org,
linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 4/4] usb: typec: Support the WUSB3801 port controller
On Mon, Jan 31, 2022 at 09:24:40PM -0600, Samuel Holland wrote:
> +static enum typec_role wusb3801_get_default_role(struct wusb3801 *wusb3801)
> +{
> + switch (wusb3801->port_type) {
> + case TYPEC_PORT_SRC:
> + return TYPEC_SOURCE;
> + case TYPEC_PORT_SNK:
> + return TYPEC_SINK;
> + case TYPEC_PORT_DRP:
> + default:
> + if (wusb3801->cap.prefer_role == TYPEC_SOURCE)
> + return TYPEC_SOURCE;
> + return TYPEC_SINK;
> + }
> +}
> +
> +static int wusb3801_map_port_type(enum typec_port_type type)
> +{
> + switch (type) {
> + case TYPEC_PORT_SRC:
> + return WUSB3801_CTRL0_ROLE_SRC;
> + case TYPEC_PORT_SNK:
> + return WUSB3801_CTRL0_ROLE_SNK;
> + case TYPEC_PORT_DRP:
> + default:
> + return WUSB3801_CTRL0_ROLE_DRP;
> + }
> +}
> +
> +static int wusb3801_map_pwr_opmode(enum typec_pwr_opmode mode)
> +{
> + switch (mode) {
> + case TYPEC_PWR_MODE_USB:
> + default:
> + return WUSB3801_CTRL0_CURRENT_DEFAULT;
> + case TYPEC_PWR_MODE_1_5A:
> + return WUSB3801_CTRL0_CURRENT_1_5A;
> + case TYPEC_PWR_MODE_3_0A:
> + return WUSB3801_CTRL0_CURRENT_3_0A;
> + }
> +}
> +
> +static unsigned int wusb3801_map_try_role(int role)
> +{
> + switch (role) {
> + case TYPEC_NO_PREFERRED_ROLE:
> + default:
> + return WUSB3801_CTRL0_TRY_NONE;
> + case TYPEC_SINK:
> + return WUSB3801_CTRL0_TRY_SNK;
> + case TYPEC_SOURCE:
> + return WUSB3801_CTRL0_TRY_SRC;
> + }
> +}
> +
> +static enum typec_orientation wusb3801_unmap_orientation(unsigned int status)
> +{
> + switch (status & WUSB3801_STAT_ORIENTATION) {
> + case WUSB3801_STAT_ORIENTATION_NONE:
> + case WUSB3801_STAT_ORIENTATION_BOTH:
> + return TYPEC_ORIENTATION_NONE;
> + case WUSB3801_STAT_ORIENTATION_CC1:
> + return TYPEC_ORIENTATION_NORMAL;
> + case WUSB3801_STAT_ORIENTATION_CC2:
> + return TYPEC_ORIENTATION_REVERSE;
> + }
> +
> + unreachable();
Some of these functions use use unreachable() and others you do not.
Pick one style and stick with it please.
thanks,
greg k-h
Powered by blists - more mailing lists