Re: [PATCH 4/4] usb: typec: Support the WUSB3801 port controller

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux