diff mbox series

usb: dwc3: drd: Don't check against CONFIG_OF

Message ID 9f15580ad5810b1e5f31c241b35ebedfbfc30a3f.1644964864.git.Thinh.Nguyen@synopsys.com
State New
Headers show
Series usb: dwc3: drd: Don't check against CONFIG_OF | expand

Commit Message

Thinh Nguyen Feb. 15, 2022, 10:49 p.m. UTC
The CONFIG_OF maybe set, but it may not be applicable to a device. In
such case, checking against that can cause the device fail to
initialize. Check against the device node (device->of_node) instead.

Fixes: a102f07e4edf ("usb: dwc3: drd: Add support for usb-conn-gpio based usb-role-switch")
Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
---
Note: This patch should go on Greg's "usb-testing" branch as the commit it
fixes is not in mainline yet.

 drivers/usb/dwc3/drd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


base-commit: 9902951f536c00b7f20c26fd98baa5432bb3c731

Comments

Alexander Stein Feb. 17, 2022, 1:50 p.m. UTC | #1
Hi Thinh,

Am Dienstag, 15. Februar 2022, 23:49:48 CET schrieb Thinh Nguyen:
> The CONFIG_OF maybe set, but it may not be applicable to a device. In
> such case, checking against that can cause the device fail to
> initialize. Check against the device node (device->of_node) instead.
> 
> Fixes: a102f07e4edf ("usb: dwc3: drd: Add support for usb-conn-gpio based
> usb-role-switch") Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
> ---
> Note: This patch should go on Greg's "usb-testing" branch as the commit it
> fixes is not in mainline yet.
> 
>  drivers/usb/dwc3/drd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c
> index 25f322e62d3f..b60b5f7b6dff 100644
> --- a/drivers/usb/dwc3/drd.c
> +++ b/drivers/usb/dwc3/drd.c
> @@ -560,7 +560,7 @@ static int dwc3_setup_role_switch(struct dwc3 *dwc)
>  	if (IS_ERR(dwc->role_sw))
>  		return PTR_ERR(dwc->role_sw);
> 
> -	if (IS_ENABLED(CONFIG_OF)) {
> +	if (dwc->dev->of_node) {
>  		/* populate connector entry */
>  		int ret = devm_of_platform_populate(dwc->dev);
> 
> 

Looks reasonable, thanks.

Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
on TQMa8MPxL using DT.

Regards,
Alexander
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c
index 25f322e62d3f..b60b5f7b6dff 100644
--- a/drivers/usb/dwc3/drd.c
+++ b/drivers/usb/dwc3/drd.c
@@ -560,7 +560,7 @@  static int dwc3_setup_role_switch(struct dwc3 *dwc)
 	if (IS_ERR(dwc->role_sw))
 		return PTR_ERR(dwc->role_sw);
 
-	if (IS_ENABLED(CONFIG_OF)) {
+	if (dwc->dev->of_node) {
 		/* populate connector entry */
 		int ret = devm_of_platform_populate(dwc->dev);