@@ -379,37 +379,6 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
379
379
return ret ;
380
380
}
381
381
382
- static int cros_typec_ec_command (struct cros_typec_data * typec ,
383
- unsigned int version ,
384
- unsigned int command ,
385
- void * outdata ,
386
- unsigned int outsize ,
387
- void * indata ,
388
- unsigned int insize )
389
- {
390
- struct cros_ec_command * msg ;
391
- int ret ;
392
-
393
- msg = kzalloc (sizeof (* msg ) + max (outsize , insize ), GFP_KERNEL );
394
- if (!msg )
395
- return - ENOMEM ;
396
-
397
- msg -> version = version ;
398
- msg -> command = command ;
399
- msg -> outsize = outsize ;
400
- msg -> insize = insize ;
401
-
402
- if (outsize )
403
- memcpy (msg -> data , outdata , outsize );
404
-
405
- ret = cros_ec_cmd_xfer_status (typec -> ec , msg );
406
- if (ret >= 0 && insize )
407
- memcpy (indata , msg -> data , insize );
408
-
409
- kfree (msg );
410
- return ret ;
411
- }
412
-
413
382
static int cros_typec_usb_safe_state (struct cros_typec_port * port )
414
383
{
415
384
port -> state .mode = TYPEC_STATE_SAFE ;
@@ -596,8 +565,8 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
596
565
/* Sending Acknowledgment to EC */
597
566
mux_ack .port = port_num ;
598
567
599
- if (cros_typec_ec_command (typec , 0 , EC_CMD_USB_PD_MUX_ACK , & mux_ack ,
600
- sizeof (mux_ack ), NULL , 0 ) < 0 )
568
+ if (cros_ec_command (typec -> ec , 0 , EC_CMD_USB_PD_MUX_ACK , & mux_ack ,
569
+ sizeof (mux_ack ), NULL , 0 ) < 0 )
601
570
dev_warn (typec -> dev ,
602
571
"Failed to send Mux ACK to EC for port: %d\n" ,
603
572
port_num );
@@ -668,8 +637,8 @@ static int cros_typec_get_mux_info(struct cros_typec_data *typec, int port_num,
668
637
.port = port_num ,
669
638
};
670
639
671
- return cros_typec_ec_command (typec , 0 , EC_CMD_USB_PD_MUX_INFO , & req ,
672
- sizeof (req ), resp , sizeof (* resp ));
640
+ return cros_ec_command (typec -> ec , 0 , EC_CMD_USB_PD_MUX_INFO , & req ,
641
+ sizeof (req ), resp , sizeof (* resp ));
673
642
}
674
643
675
644
/*
@@ -776,8 +745,8 @@ static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int p
776
745
int ret = 0 ;
777
746
778
747
memset (disc , 0 , EC_PROTO2_MAX_RESPONSE_SIZE );
779
- ret = cros_typec_ec_command (typec , 0 , EC_CMD_TYPEC_DISCOVERY , & req , sizeof (req ),
780
- disc , EC_PROTO2_MAX_RESPONSE_SIZE );
748
+ ret = cros_ec_command (typec -> ec , 0 , EC_CMD_TYPEC_DISCOVERY , & req , sizeof (req ),
749
+ disc , EC_PROTO2_MAX_RESPONSE_SIZE );
781
750
if (ret < 0 ) {
782
751
dev_err (typec -> dev , "Failed to get SOP' discovery data for port: %d\n" , port_num );
783
752
goto sop_prime_disc_exit ;
@@ -859,8 +828,8 @@ static int cros_typec_handle_sop_disc(struct cros_typec_data *typec, int port_nu
859
828
typec_partner_set_pd_revision (port -> partner , pd_revision );
860
829
861
830
memset (sop_disc , 0 , EC_PROTO2_MAX_RESPONSE_SIZE );
862
- ret = cros_typec_ec_command (typec , 0 , EC_CMD_TYPEC_DISCOVERY , & req , sizeof (req ),
863
- sop_disc , EC_PROTO2_MAX_RESPONSE_SIZE );
831
+ ret = cros_ec_command (typec -> ec , 0 , EC_CMD_TYPEC_DISCOVERY , & req , sizeof (req ),
832
+ sop_disc , EC_PROTO2_MAX_RESPONSE_SIZE );
864
833
if (ret < 0 ) {
865
834
dev_err (typec -> dev , "Failed to get SOP discovery data for port: %d\n" , port_num );
866
835
goto disc_exit ;
@@ -892,8 +861,8 @@ static int cros_typec_send_clear_event(struct cros_typec_data *typec, int port_n
892
861
.clear_events_mask = events_mask ,
893
862
};
894
863
895
- return cros_typec_ec_command (typec , 0 , EC_CMD_TYPEC_CONTROL , & req ,
896
- sizeof (req ), NULL , 0 );
864
+ return cros_ec_command (typec -> ec , 0 , EC_CMD_TYPEC_CONTROL , & req ,
865
+ sizeof (req ), NULL , 0 );
897
866
}
898
867
899
868
static void cros_typec_handle_status (struct cros_typec_data * typec , int port_num )
@@ -904,8 +873,8 @@ static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num
904
873
};
905
874
int ret ;
906
875
907
- ret = cros_typec_ec_command (typec , 0 , EC_CMD_TYPEC_STATUS , & req , sizeof (req ),
908
- & resp , sizeof (resp ));
876
+ ret = cros_ec_command (typec -> ec , 0 , EC_CMD_TYPEC_STATUS , & req , sizeof (req ),
877
+ & resp , sizeof (resp ));
909
878
if (ret < 0 ) {
910
879
dev_warn (typec -> dev , "EC_CMD_TYPEC_STATUS failed for port: %d\n" , port_num );
911
880
return ;
@@ -983,9 +952,9 @@ static int cros_typec_port_update(struct cros_typec_data *typec, int port_num)
983
952
req .mux = USB_PD_CTRL_MUX_NO_CHANGE ;
984
953
req .swap = USB_PD_CTRL_SWAP_NONE ;
985
954
986
- ret = cros_typec_ec_command (typec , typec -> pd_ctrl_ver ,
987
- EC_CMD_USB_PD_CONTROL , & req , sizeof (req ),
988
- & resp , sizeof (resp ));
955
+ ret = cros_ec_command (typec -> ec , typec -> pd_ctrl_ver ,
956
+ EC_CMD_USB_PD_CONTROL , & req , sizeof (req ),
957
+ & resp , sizeof (resp ));
989
958
if (ret < 0 )
990
959
return ret ;
991
960
@@ -1035,8 +1004,8 @@ static int cros_typec_get_cmd_version(struct cros_typec_data *typec)
1035
1004
1036
1005
/* We're interested in the PD control command version. */
1037
1006
req_v1 .cmd = EC_CMD_USB_PD_CONTROL ;
1038
- ret = cros_typec_ec_command (typec , 1 , EC_CMD_GET_CMD_VERSIONS ,
1039
- & req_v1 , sizeof (req_v1 ), & resp ,
1007
+ ret = cros_ec_command (typec -> ec , 1 , EC_CMD_GET_CMD_VERSIONS ,
1008
+ & req_v1 , sizeof (req_v1 ), & resp ,
1040
1009
sizeof (resp ));
1041
1010
if (ret < 0 )
1042
1011
return ret ;
@@ -1119,8 +1088,8 @@ static int cros_typec_probe(struct platform_device *pdev)
1119
1088
typec -> typec_cmd_supported = cros_ec_check_features (ec_dev , EC_FEATURE_TYPEC_CMD );
1120
1089
typec -> needs_mux_ack = cros_ec_check_features (ec_dev , EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK );
1121
1090
1122
- ret = cros_typec_ec_command (typec , 0 , EC_CMD_USB_PD_PORTS , NULL , 0 ,
1123
- & resp , sizeof (resp ));
1091
+ ret = cros_ec_command (typec -> ec , 0 , EC_CMD_USB_PD_PORTS , NULL , 0 ,
1092
+ & resp , sizeof (resp ));
1124
1093
if (ret < 0 )
1125
1094
return ret ;
1126
1095
0 commit comments