Re: [PATCH 2/2] usb: typec: tcpci: support setting orientation via GPIO
From: Frank Li
Date: Tue Mar 10 2026 - 14:34:36 EST
From: Frank Li (AI-BOT) <frank.li@xxxxxxx>
> + if (err == 0) {
> + orient_gpio = devm_gpiod_get_optional(&client->dev, "orientation",
> + GPIOD_OUT_LOW);
> + if (IS_ERR(orient_gpio))
> + return dev_err_probe(&client->dev, PTR_ERR(orient_gpio),
> + "unable to acquire orientation gpio\n");
> + err = !!orient_gpio;
> + }
AI: The logic here is confusing. You're converting a pointer to a boolean with
`!!orient_gpio`, then assigning it to `err`. This overwrites the error code
and makes the intent unclear. Consider using a separate flag variable or
restructuring to keep error handling explicit.
> + chip->tcpci->orientation_gpio = orient_gpio;
> +
> + err = devm_request_threaded_irq(&client->dev, client->irq, NULL,
AI: This assignment happens after `tcpci_register_port()` returns. If that
function or any subsequent code path fails before this line, the GPIO
pointer is never stored in the chip structure. Consider moving the
assignment immediately after the GPIO acquisition, or ensure the pointer
is initialized in the struct at declaration time.
Frank