@@ -33,7 +33,8 @@ static __u8 ocp_C2_guid[SNDK_GUID_LENGTH] = {
3333 0xE2 , 0x4D , 0xB2 , 0x8A , 0xAC , 0xF3 , 0x1C , 0xD1
3434};
3535
36- static int sndk_do_cap_telemetry_log (struct nvme_transport_handle * hdl ,
36+ static int sndk_do_cap_telemetry_log (struct nvme_global_ctx * ctx ,
37+ struct nvme_transport_handle * hdl ,
3738 const char * file , __u32 bs , int type ,
3839 int data_area )
3940{
@@ -47,7 +48,6 @@ static int sndk_do_cap_telemetry_log(struct nvme_transport_handle *hdl,
4748 struct nvme_id_ctrl ctrl ;
4849 __u64 capabilities = 0 ;
4950 bool host_behavior_changed = false;
50- struct nvme_global_ctx * ctx ;
5151
5252 memset (& ctrl , 0 , sizeof (struct nvme_id_ctrl ));
5353 err = nvme_identify_ctrl (hdl , & ctrl );
@@ -61,7 +61,7 @@ static int sndk_do_cap_telemetry_log(struct nvme_transport_handle *hdl,
6161 return - EINVAL ;
6262 }
6363
64- err = nvme_scan ( NULL , & ctx );
64+ err = nvme_scan_topology ( ctx , NULL , NULL );
6565 if (err )
6666 return err ;
6767 capabilities = sndk_get_drive_capabilities (ctx , hdl );
@@ -343,7 +343,7 @@ static int sndk_vs_internal_fw_log(int argc, char **argv,
343343 if (ret )
344344 return ret ;
345345
346- ret = nvme_scan ( NULL , & ctx );
346+ ret = nvme_scan_topology ( ctx , NULL , NULL );
347347 if (ret || !sndk_check_device (ctx , hdl ))
348348 goto out ;
349349
@@ -427,7 +427,7 @@ static int sndk_vs_internal_fw_log(int argc, char **argv,
427427 if (!telemetry_data_area )
428428 telemetry_data_area = 3 ;
429429
430- ret = sndk_do_cap_telemetry_log (hdl , f , xfer_size ,
430+ ret = sndk_do_cap_telemetry_log (ctx , hdl , f , xfer_size ,
431431 telemetry_type , telemetry_data_area );
432432 goto out ;
433433 }
@@ -439,7 +439,7 @@ static int sndk_vs_internal_fw_log(int argc, char **argv,
439439 if (!telemetry_data_area )
440440 telemetry_data_area = 3 ;
441441
442- ret = sndk_do_cap_telemetry_log (hdl , f , xfer_size ,
442+ ret = sndk_do_cap_telemetry_log (ctx , hdl , f , xfer_size ,
443443 telemetry_type , telemetry_data_area );
444444 goto out ;
445445 } else {
@@ -547,7 +547,7 @@ static int sndk_drive_resize(int argc, char **argv,
547547 if (ret )
548548 return ret ;
549549
550- ret = nvme_scan ( NULL , & ctx );
550+ ret = nvme_scan_topology ( ctx , NULL , NULL );
551551 if (ret )
552552 return ret ;
553553 sndk_check_device (ctx , hdl );
@@ -879,7 +879,7 @@ static int sndk_vs_fw_activate_history(int argc, char **argv,
879879 _cleanup_nvme_global_ctx_ struct nvme_global_ctx * ctx = NULL ;
880880 _cleanup_nvme_transport_handle_ struct nvme_transport_handle * hdl = NULL ;
881881 uint64_t capabilities = 0 ;
882- int ret = -1 ;
882+ int ret ;
883883
884884 struct config {
885885 char * output_format ;
@@ -898,7 +898,7 @@ static int sndk_vs_fw_activate_history(int argc, char **argv,
898898 if (ret )
899899 return ret ;
900900
901- ret = nvme_scan ( NULL , & ctx );
901+ ret = nvme_scan_topology ( ctx , NULL , NULL );
902902 if (ret )
903903 return ret ;
904904 capabilities = sndk_get_drive_capabilities (ctx , hdl );
@@ -948,10 +948,10 @@ static int sndk_clear_fw_activate_history(int argc, char **argv,
948948 if (ret )
949949 return ret ;
950950
951- ret = nvme_scan ( NULL , & ctx );
951+ ret = nvme_scan_topology ( ctx , NULL , NULL );
952952 if (ret )
953953 return ret ;
954- capabilities = sndk_get_drive_capabilities (ctx , hdl );
954+ capabilities = sndk_get_drive_capabilities (ctx , hdl );
955955
956956 if (capabilities & SNDK_DRIVE_CAP_VU_FID_CLEAR_FW_ACT_HISTORY ) {
957957 ret = sndk_do_clear_fw_activate_history_fid (hdl );
@@ -1021,11 +1021,10 @@ static int sndk_capabilities(int argc, char **argv,
10211021 return ret ;
10221022
10231023 /* get capabilities */
1024- ret = nvme_scan ( NULL , & ctx );
1025- if (ret )
1026- return ret ;
1024+ ret = nvme_scan_topology ( ctx , NULL , NULL );
1025+ if (ret || sndk_check_device ( ctx , hdl ) )
1026+ return -1 ;
10271027
1028- sndk_check_device (ctx , hdl );
10291028 capabilities = sndk_get_drive_capabilities (ctx , hdl );
10301029
10311030 /* print command and supported status */
0 commit comments