@@ -30,55 +30,64 @@ static void schedule_detach(void *cxlmd)
30
30
schedule_cxl_memdev_detach (cxlmd );
31
31
}
32
32
33
- static int cxl_port_probe (struct device * dev )
33
+ static int cxl_switch_port_probe (struct cxl_port * port )
34
34
{
35
- struct cxl_port * port = to_cxl_port (dev );
36
35
struct cxl_hdm * cxlhdm ;
37
36
int rc ;
38
37
38
+ rc = devm_cxl_port_enumerate_dports (port );
39
+ if (rc < 0 )
40
+ return rc ;
39
41
40
- if (!is_cxl_endpoint (port )) {
41
- rc = devm_cxl_port_enumerate_dports (port );
42
- if (rc < 0 )
43
- return rc ;
44
- if (rc == 1 )
45
- return devm_cxl_add_passthrough_decoder (port );
46
- }
42
+ if (rc == 1 )
43
+ return devm_cxl_add_passthrough_decoder (port );
47
44
48
45
cxlhdm = devm_cxl_setup_hdm (port );
49
46
if (IS_ERR (cxlhdm ))
50
47
return PTR_ERR (cxlhdm );
51
48
52
- if (is_cxl_endpoint (port )) {
53
- struct cxl_memdev * cxlmd = to_cxl_memdev (port -> uport );
54
- struct cxl_dev_state * cxlds = cxlmd -> cxlds ;
49
+ return devm_cxl_enumerate_decoders (cxlhdm );
50
+ }
55
51
56
- /* Cache the data early to ensure is_visible() works */
57
- read_cdat_data (port );
52
+ static int cxl_endpoint_port_probe (struct cxl_port * port )
53
+ {
54
+ struct cxl_memdev * cxlmd = to_cxl_memdev (port -> uport );
55
+ struct cxl_dev_state * cxlds = cxlmd -> cxlds ;
56
+ struct cxl_hdm * cxlhdm ;
57
+ int rc ;
58
+
59
+ cxlhdm = devm_cxl_setup_hdm (port );
60
+ if (IS_ERR (cxlhdm ))
61
+ return PTR_ERR (cxlhdm );
58
62
59
- get_device (& cxlmd -> dev );
60
- rc = devm_add_action_or_reset (dev , schedule_detach , cxlmd );
61
- if (rc )
62
- return rc ;
63
+ /* Cache the data early to ensure is_visible() works */
64
+ read_cdat_data (port );
63
65
64
- rc = cxl_hdm_decode_init (cxlds , cxlhdm );
65
- if (rc )
66
- return rc ;
66
+ get_device (& cxlmd -> dev );
67
+ rc = devm_add_action_or_reset (& port -> dev , schedule_detach , cxlmd );
68
+ if (rc )
69
+ return rc ;
67
70
68
- rc = cxl_await_media_ready (cxlds );
69
- if (rc ) {
70
- dev_err (dev , "Media not active (%d)\n" , rc );
71
- return rc ;
72
- }
73
- }
71
+ rc = cxl_hdm_decode_init (cxlds , cxlhdm );
72
+ if (rc )
73
+ return rc ;
74
74
75
- rc = devm_cxl_enumerate_decoders ( cxlhdm );
75
+ rc = cxl_await_media_ready ( cxlds );
76
76
if (rc ) {
77
- dev_err (dev , "Couldn't enumerate decoders (%d)\n" , rc );
77
+ dev_err (& port -> dev , "Media not active (%d)\n" , rc );
78
78
return rc ;
79
79
}
80
80
81
- return 0 ;
81
+ return devm_cxl_enumerate_decoders (cxlhdm );
82
+ }
83
+
84
+ static int cxl_port_probe (struct device * dev )
85
+ {
86
+ struct cxl_port * port = to_cxl_port (dev );
87
+
88
+ if (is_cxl_endpoint (port ))
89
+ return cxl_endpoint_port_probe (port );
90
+ return cxl_switch_port_probe (port );
82
91
}
83
92
84
93
static ssize_t CDAT_read (struct file * filp , struct kobject * kobj ,
0 commit comments