[PATCH v3] usb: cdns3: use VBUS Valid to determine role for dr_mode OTG

Marek Vasut marek.vasut at mailbox.org
Sun Feb 15 16:58:00 CET 2026


On 2/15/26 1:35 PM, Siddharth Vadapalli wrote:

[...]

> +static int cdns3_get_otg_mode(struct udevice *parent, enum usb_dr_mode *mode)
> +{
> +	/* Create a temporary child device for using devfdt_remap_addr_name() */
> +	struct udevice child = {
> +		.parent = parent,
> +	};
> +	struct cdns3 cdns, *cdnsp;
> +	void __iomem *otg_regs;
> +	int vbus;

[...]

> +	/* Use VBUS Valid to determine role */
> +	vbus = !!(readl(&cdnsp->otg_regs->sts) & OTGSTS_VBUS_VALID);
> +	if (vbus)
The double-negation is not needed here, simply use:

if (readl(&cdnsp->otg_regs->sts) & OTGSTS_VBUS_VALID) {
...


More information about the U-Boot mailing list