@@ -840,43 +840,22 @@ static void load_fw_from_host_handler(struct work_struct *work)
840
840
*
841
841
* Return: 0 for success, negative error code for failure
842
842
*/
843
- static int loader_init (struct ishtp_cl * loader_ishtp_cl , int reset )
843
+ static int loader_init (struct ishtp_cl * loader_ishtp_cl , bool reset )
844
844
{
845
845
int rv ;
846
- struct ishtp_fw_client * fw_client ;
847
846
struct ishtp_cl_data * client_data =
848
847
ishtp_get_client_data (loader_ishtp_cl );
849
848
850
849
dev_dbg (cl_data_to_dev (client_data ), "reset flag: %d\n" , reset );
851
850
852
- rv = ishtp_cl_link (loader_ishtp_cl );
853
- if (rv < 0 ) {
854
- dev_err (cl_data_to_dev (client_data ), "ishtp_cl_link failed\n" );
855
- return rv ;
856
- }
857
-
858
- /* Connect to firmware client */
859
- ishtp_set_tx_ring_size (loader_ishtp_cl , LOADER_CL_TX_RING_SIZE );
860
- ishtp_set_rx_ring_size (loader_ishtp_cl , LOADER_CL_RX_RING_SIZE );
861
-
862
- fw_client =
863
- ishtp_fw_cl_get_client (ishtp_get_ishtp_device (loader_ishtp_cl ),
864
- & loader_ishtp_id_table [0 ].guid );
865
- if (!fw_client ) {
866
- dev_err (cl_data_to_dev (client_data ),
867
- "ISH client uuid not found\n" );
868
- rv = - ENOENT ;
869
- goto err_cl_unlink ;
870
- }
871
-
872
- ishtp_cl_set_fw_client_id (loader_ishtp_cl ,
873
- ishtp_get_fw_client_id (fw_client ));
874
- ishtp_set_connection_state (loader_ishtp_cl , ISHTP_CL_CONNECTING );
875
-
876
- rv = ishtp_cl_connect (loader_ishtp_cl );
851
+ rv = ishtp_cl_establish_connection (loader_ishtp_cl ,
852
+ & loader_ishtp_id_table [0 ].guid ,
853
+ LOADER_CL_TX_RING_SIZE ,
854
+ LOADER_CL_RX_RING_SIZE ,
855
+ reset );
877
856
if (rv < 0 ) {
878
857
dev_err (cl_data_to_dev (client_data ), "Client connect fail\n" );
879
- goto err_cl_unlink ;
858
+ goto err_cl_disconnect ;
880
859
}
881
860
882
861
dev_dbg (cl_data_to_dev (client_data ), "Client connected\n" );
@@ -885,17 +864,14 @@ static int loader_init(struct ishtp_cl *loader_ishtp_cl, int reset)
885
864
886
865
return 0 ;
887
866
888
- err_cl_unlink :
889
- ishtp_cl_unlink (loader_ishtp_cl );
867
+ err_cl_disconnect :
868
+ ishtp_cl_destroy_connection (loader_ishtp_cl , reset );
890
869
return rv ;
891
870
}
892
871
893
872
static void loader_deinit (struct ishtp_cl * loader_ishtp_cl )
894
873
{
895
- ishtp_set_connection_state (loader_ishtp_cl , ISHTP_CL_DISCONNECTING );
896
- ishtp_cl_disconnect (loader_ishtp_cl );
897
- ishtp_cl_unlink (loader_ishtp_cl );
898
- ishtp_cl_flush_queues (loader_ishtp_cl );
874
+ ishtp_cl_destroy_connection (loader_ishtp_cl , false);
899
875
900
876
/* Disband and free all Tx and Rx client-level rings */
901
877
ishtp_cl_free (loader_ishtp_cl );
@@ -914,19 +890,7 @@ static void reset_handler(struct work_struct *work)
914
890
loader_ishtp_cl = client_data -> loader_ishtp_cl ;
915
891
cl_device = client_data -> cl_device ;
916
892
917
- /* Unlink, flush queues & start again */
918
- ishtp_cl_unlink (loader_ishtp_cl );
919
- ishtp_cl_flush_queues (loader_ishtp_cl );
920
- ishtp_cl_free (loader_ishtp_cl );
921
-
922
- loader_ishtp_cl = ishtp_cl_allocate (cl_device );
923
- if (!loader_ishtp_cl )
924
- return ;
925
-
926
- ishtp_set_drvdata (cl_device , loader_ishtp_cl );
927
- ishtp_set_client_data (loader_ishtp_cl , client_data );
928
- client_data -> loader_ishtp_cl = loader_ishtp_cl ;
929
- client_data -> cl_device = cl_device ;
893
+ ishtp_cl_destroy_connection (loader_ishtp_cl , true);
930
894
931
895
rv = loader_init (loader_ishtp_cl , 1 );
932
896
if (rv < 0 ) {
@@ -974,7 +938,7 @@ static int loader_ishtp_cl_probe(struct ishtp_cl_device *cl_device)
974
938
INIT_WORK (& client_data -> work_fw_load ,
975
939
load_fw_from_host_handler );
976
940
977
- rv = loader_init (loader_ishtp_cl , 0 );
941
+ rv = loader_init (loader_ishtp_cl , false );
978
942
if (rv < 0 ) {
979
943
ishtp_cl_free (loader_ishtp_cl );
980
944
return rv ;
0 commit comments