Re: [PATCH v2 2/2] usb: typec: ucsi_ccg: Add CC orientation sensing via GPIO

From: Heikki Krogerus

Date: Fri Nov 20 2026 - 09:52:20 EST


Hi,

> +static void ucsi_ccg_connector_status(struct ucsi_connector *con)
> +{
> + struct ucsi_ccg *uc = ucsi_get_drvdata(con->ucsi);
> + int orientation;
> +
> + if (!UCSI_CONSTAT(con, CONNECTED)) {
> + typec_set_orientation(con->port, TYPEC_ORIENTATION_NONE);
> + return;
> + }
> +
> + if (con->num > CCG_MAX_PORTS || !uc->orientation_gpio[con->num - 1])
> + return;
> +
> + orientation = gpiod_get_value_cansleep(uc->orientation_gpio[con->num - 1]);
> + if (orientation >= 0)
> + typec_set_orientation(con->port,
> + orientation ? TYPEC_ORIENTATION_REVERSE :
> + TYPEC_ORIENTATION_NORMAL);
> +}

Looks like you have a small allignment issue here.

Maybe it would be more clear to return if the orientation is < 0.

orientation = gpiod_get_value_cansleep(uc->orientation_gpio[con->num - 1]);
if (orientation < 0)
return;

typec_set_orientation(con->port, orientation ? TYPEC_ORIENTATION_REVERSE :
TYPEC_ORIENTATION_NORMAL);

Thanks,

--
heikki