@@ -763,9 +763,9 @@ static int dwc3_qcom_of_register_core(struct platform_device *pdev)
763
763
return ret ;
764
764
}
765
765
766
- static struct platform_device *
767
- dwc3_qcom_create_urs_usb_platdev (struct device * dev )
766
+ static struct platform_device * dwc3_qcom_create_urs_usb_platdev (struct device * dev )
768
767
{
768
+ struct platform_device * urs_usb = NULL ;
769
769
struct fwnode_handle * fwh ;
770
770
struct acpi_device * adev ;
771
771
char name [8 ];
@@ -785,9 +785,26 @@ dwc3_qcom_create_urs_usb_platdev(struct device *dev)
785
785
786
786
adev = to_acpi_device_node (fwh );
787
787
if (!adev )
788
- return NULL ;
788
+ goto err_put_handle ;
789
+
790
+ urs_usb = acpi_create_platform_device (adev , NULL );
791
+ if (IS_ERR_OR_NULL (urs_usb ))
792
+ goto err_put_handle ;
793
+
794
+ return urs_usb ;
789
795
790
- return acpi_create_platform_device (adev , NULL );
796
+ err_put_handle :
797
+ fwnode_handle_put (fwh );
798
+
799
+ return urs_usb ;
800
+ }
801
+
802
+ static void dwc3_qcom_destroy_urs_usb_platdev (struct platform_device * urs_usb )
803
+ {
804
+ struct fwnode_handle * fwh = urs_usb -> dev .fwnode ;
805
+
806
+ platform_device_unregister (urs_usb );
807
+ fwnode_handle_put (fwh );
791
808
}
792
809
793
810
static int dwc3_qcom_probe (struct platform_device * pdev )
@@ -871,13 +888,13 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
871
888
qcom -> qscratch_base = devm_ioremap_resource (dev , parent_res );
872
889
if (IS_ERR (qcom -> qscratch_base )) {
873
890
ret = PTR_ERR (qcom -> qscratch_base );
874
- goto clk_disable ;
891
+ goto free_urs ;
875
892
}
876
893
877
894
ret = dwc3_qcom_setup_irq (pdev );
878
895
if (ret ) {
879
896
dev_err (dev , "failed to setup IRQs, err=%d\n" , ret );
880
- goto clk_disable ;
897
+ goto free_urs ;
881
898
}
882
899
883
900
/*
@@ -896,7 +913,7 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
896
913
897
914
if (ret ) {
898
915
dev_err (dev , "failed to register DWC3 Core, err=%d\n" , ret );
899
- goto clk_disable ;
916
+ goto free_urs ;
900
917
}
901
918
902
919
ret = dwc3_qcom_interconnect_init (qcom );
@@ -935,6 +952,9 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
935
952
platform_device_del (qcom -> dwc3 );
936
953
}
937
954
platform_device_put (qcom -> dwc3 );
955
+ free_urs :
956
+ if (qcom -> urs_usb )
957
+ dwc3_qcom_destroy_urs_usb_platdev (qcom -> urs_usb );
938
958
clk_disable :
939
959
for (i = qcom -> num_clocks - 1 ; i >= 0 ; i -- ) {
940
960
clk_disable_unprepare (qcom -> clks [i ]);
@@ -961,6 +981,9 @@ static void dwc3_qcom_remove(struct platform_device *pdev)
961
981
}
962
982
platform_device_put (qcom -> dwc3 );
963
983
984
+ if (qcom -> urs_usb )
985
+ dwc3_qcom_destroy_urs_usb_platdev (qcom -> urs_usb );
986
+
964
987
for (i = qcom -> num_clocks - 1 ; i >= 0 ; i -- ) {
965
988
clk_disable_unprepare (qcom -> clks [i ]);
966
989
clk_put (qcom -> clks [i ]);
0 commit comments