diff mbox series

[v2,1/1] usb: dwc3: drd: Add support for usb-conn-gpio based usb-role-switch

Message ID 20211125141516.1668633-1-alexander.stein@ew.tq-group.com (mailing list archive)
State Superseded
Headers show
Series [v2,1/1] usb: dwc3: drd: Add support for usb-conn-gpio based usb-role-switch | expand

Commit Message

Alexander Stein Nov. 25, 2021, 2:15 p.m. UTC
usb-conn-gpio devices are a subnode of the USB interface controller, which
needs to be populated.
This allows having a non-type-c connector providing dual-role.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
Changes in v2:
* Added missing variable declaration

 drivers/usb/dwc3/drd.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Greg Kroah-Hartman Dec. 3, 2021, 11:02 a.m. UTC | #1
On Thu, Nov 25, 2021 at 03:15:16PM +0100, Alexander Stein wrote:
> usb-conn-gpio devices are a subnode of the USB interface controller, which
> needs to be populated.
> This allows having a non-type-c connector providing dual-role.
> 
> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
> ---
> Changes in v2:
> * Added missing variable declaration
> 
>  drivers/usb/dwc3/drd.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c
> index d7f76835137f..8b5ac689b8da 100644
> --- a/drivers/usb/dwc3/drd.c
> +++ b/drivers/usb/dwc3/drd.c
> @@ -9,6 +9,7 @@
>  
>  #include <linux/extcon.h>
>  #include <linux/of_graph.h>
> +#include "linux/of_platform.h"
>  #include <linux/platform_device.h>
>  #include <linux/property.h>
>  
> @@ -542,6 +543,7 @@ static int dwc3_setup_role_switch(struct dwc3 *dwc)
>  {
>  	struct usb_role_switch_desc dwc3_role_switch = {NULL};
>  	u32 mode;
> +	int ret;
>  
>  	dwc->role_switch_default_mode = usb_get_role_switch_default_mode(dwc->dev);
>  	if (dwc->role_switch_default_mode == USB_DR_MODE_HOST) {
> @@ -559,6 +561,13 @@ static int dwc3_setup_role_switch(struct dwc3 *dwc)
>  	if (IS_ERR(dwc->role_sw))
>  		return PTR_ERR(dwc->role_sw);
>  
> +	/* populate connector entry */
> +	ret = devm_of_platform_populate(dwc->dev);
> +	if (ret) {
> +		dev_err(dwc->dev, "DWC3 platform devices creation failed: %i\n", ret);
> +		return ret;
> +	}

You do not have to unwind what usb_role_switch_register() did here if
there is an error?

And will ALL systems always succeed at the call to
devm_of_platform_populate()?  Or will this break older systems that are
running today?  What was this tested with?

thanks,

greg k-h
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c
index d7f76835137f..8b5ac689b8da 100644
--- a/drivers/usb/dwc3/drd.c
+++ b/drivers/usb/dwc3/drd.c
@@ -9,6 +9,7 @@ 
 
 #include <linux/extcon.h>
 #include <linux/of_graph.h>
+#include "linux/of_platform.h"
 #include <linux/platform_device.h>
 #include <linux/property.h>
 
@@ -542,6 +543,7 @@  static int dwc3_setup_role_switch(struct dwc3 *dwc)
 {
 	struct usb_role_switch_desc dwc3_role_switch = {NULL};
 	u32 mode;
+	int ret;
 
 	dwc->role_switch_default_mode = usb_get_role_switch_default_mode(dwc->dev);
 	if (dwc->role_switch_default_mode == USB_DR_MODE_HOST) {
@@ -559,6 +561,13 @@  static int dwc3_setup_role_switch(struct dwc3 *dwc)
 	if (IS_ERR(dwc->role_sw))
 		return PTR_ERR(dwc->role_sw);
 
+	/* populate connector entry */
+	ret = devm_of_platform_populate(dwc->dev);
+	if (ret) {
+		dev_err(dwc->dev, "DWC3 platform devices creation failed: %i\n", ret);
+		return ret;
+	}
+
 	dwc3_set_mode(dwc, mode);
 	return 0;
 }