Commit 91c0e9d
cxl/port: Refactor __devm_cxl_add_port() to drop goto pattern
In __devm_cxl_add_port(), there is a 'goto' to call put_device() for the
error cases between device_initialize() and device_add() to dereference
the 'struct device' of a new cxl_port. The 'goto' pattern in the case
can be removed by refactoring. Introducing a new function called
cxl_port_add() which is used to add the 'struct device' of a new
cxl_port to device hierarchy, moving the functions needing the help of
the 'goto' into cxl_port_add(), and using a scoped-based resource
management __free() to drop the open coded put_device() and the 'goto'
for the error cases.
Suggested-by: Dan Williams <[email protected]>
Signed-off-by: Li Ming <[email protected]>
Reviewed-by: Ira Weiny <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Dave Jiang <[email protected]>1 parent 7f569e9 commit 91c0e9d
1 file changed
+35
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
828 | 828 | | |
829 | 829 | | |
830 | 830 | | |
831 | | - | |
832 | | - | |
833 | | - | |
834 | | - | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
835 | 834 | | |
836 | | - | |
837 | | - | |
| 835 | + | |
838 | 836 | | |
839 | 837 | | |
840 | | - | |
841 | | - | |
842 | | - | |
843 | | - | |
844 | | - | |
845 | | - | |
846 | | - | |
| 838 | + | |
| 839 | + | |
847 | 840 | | |
848 | 841 | | |
849 | 842 | | |
850 | 843 | | |
851 | | - | |
| 844 | + | |
852 | 845 | | |
853 | 846 | | |
854 | 847 | | |
| |||
861 | 854 | | |
862 | 855 | | |
863 | 856 | | |
864 | | - | |
| 857 | + | |
865 | 858 | | |
866 | 859 | | |
867 | 860 | | |
868 | | - | |
869 | | - | |
| 861 | + | |
| 862 | + | |
870 | 863 | | |
871 | | - | |
872 | | - | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
873 | 867 | | |
874 | 868 | | |
875 | 869 | | |
876 | | - | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
877 | 892 | | |
878 | 893 | | |
879 | 894 | | |
| |||
891 | 906 | | |
892 | 907 | | |
893 | 908 | | |
894 | | - | |
895 | | - | |
896 | | - | |
897 | | - | |
898 | 909 | | |
899 | 910 | | |
900 | 911 | | |
| |||
0 commit comments