@@ -639,47 +639,26 @@ static int ishtp_get_report_descriptor(struct ishtp_cl *hid_ishtp_cl,
639
639
*
640
640
* Return: 0 on success, non zero on error
641
641
*/
642
- static int hid_ishtp_cl_init (struct ishtp_cl * hid_ishtp_cl , int reset )
642
+ static int hid_ishtp_cl_init (struct ishtp_cl * hid_ishtp_cl , bool reset )
643
643
{
644
- struct ishtp_device * dev ;
645
644
struct ishtp_cl_data * client_data = ishtp_get_client_data (hid_ishtp_cl );
646
- struct ishtp_fw_client * fw_client ;
647
645
int i ;
648
646
int rv ;
649
647
650
648
dev_dbg (cl_data_to_dev (client_data ), "%s\n" , __func__ );
651
649
hid_ishtp_trace (client_data , "%s reset flag: %d\n" , __func__ , reset );
652
650
653
- rv = ishtp_cl_link (hid_ishtp_cl );
654
- if (rv ) {
655
- dev_err (cl_data_to_dev (client_data ),
656
- "ishtp_cl_link failed\n" );
657
- return - ENOMEM ;
658
- }
659
-
660
651
client_data -> init_done = 0 ;
661
652
662
- dev = ishtp_get_ishtp_device (hid_ishtp_cl );
663
-
664
- /* Connect to FW client */
665
- ishtp_set_tx_ring_size (hid_ishtp_cl , HID_CL_TX_RING_SIZE );
666
- ishtp_set_rx_ring_size (hid_ishtp_cl , HID_CL_RX_RING_SIZE );
667
-
668
- fw_client = ishtp_fw_cl_get_client (dev , & hid_ishtp_id_table [0 ].guid );
669
- if (!fw_client ) {
670
- dev_err (cl_data_to_dev (client_data ),
671
- "ish client uuid not found\n" );
672
- return - ENOENT ;
673
- }
674
- ishtp_cl_set_fw_client_id (hid_ishtp_cl ,
675
- ishtp_get_fw_client_id (fw_client ));
676
- ishtp_set_connection_state (hid_ishtp_cl , ISHTP_CL_CONNECTING );
677
-
678
- rv = ishtp_cl_connect (hid_ishtp_cl );
653
+ rv = ishtp_cl_establish_connection (hid_ishtp_cl ,
654
+ & hid_ishtp_id_table [0 ].guid ,
655
+ HID_CL_TX_RING_SIZE ,
656
+ HID_CL_RX_RING_SIZE ,
657
+ reset );
679
658
if (rv ) {
680
659
dev_err (cl_data_to_dev (client_data ),
681
660
"client connect fail\n" );
682
- goto err_cl_unlink ;
661
+ goto err_cl_disconnect ;
683
662
}
684
663
685
664
hid_ishtp_trace (client_data , "%s client connected\n" , __func__ );
@@ -723,10 +702,7 @@ static int hid_ishtp_cl_init(struct ishtp_cl *hid_ishtp_cl, int reset)
723
702
return 0 ;
724
703
725
704
err_cl_disconnect :
726
- ishtp_set_connection_state (hid_ishtp_cl , ISHTP_CL_DISCONNECTING );
727
- ishtp_cl_disconnect (hid_ishtp_cl );
728
- err_cl_unlink :
729
- ishtp_cl_unlink (hid_ishtp_cl );
705
+ ishtp_cl_destroy_connection (hid_ishtp_cl , reset );
730
706
return rv ;
731
707
}
732
708
@@ -738,8 +714,7 @@ static int hid_ishtp_cl_init(struct ishtp_cl *hid_ishtp_cl, int reset)
738
714
*/
739
715
static void hid_ishtp_cl_deinit (struct ishtp_cl * hid_ishtp_cl )
740
716
{
741
- ishtp_cl_unlink (hid_ishtp_cl );
742
- ishtp_cl_flush_queues (hid_ishtp_cl );
717
+ ishtp_cl_destroy_connection (hid_ishtp_cl , false);
743
718
744
719
/* disband and free all Tx and Rx client-level rings */
745
720
ishtp_cl_free (hid_ishtp_cl );
@@ -749,33 +724,23 @@ static void hid_ishtp_cl_reset_handler(struct work_struct *work)
749
724
{
750
725
struct ishtp_cl_data * client_data ;
751
726
struct ishtp_cl * hid_ishtp_cl ;
752
- struct ishtp_cl_device * cl_device ;
753
727
int retry ;
754
728
int rv ;
755
729
756
730
client_data = container_of (work , struct ishtp_cl_data , work );
757
731
758
732
hid_ishtp_cl = client_data -> hid_ishtp_cl ;
759
- cl_device = client_data -> cl_device ;
760
733
761
734
hid_ishtp_trace (client_data , "%s hid_ishtp_cl %p\n" , __func__ ,
762
735
hid_ishtp_cl );
763
736
dev_dbg (ishtp_device (client_data -> cl_device ), "%s\n" , __func__ );
764
737
765
- hid_ishtp_cl_deinit (hid_ishtp_cl );
766
-
767
- hid_ishtp_cl = ishtp_cl_allocate (cl_device );
768
- if (!hid_ishtp_cl )
769
- return ;
770
-
771
- ishtp_set_drvdata (cl_device , hid_ishtp_cl );
772
- ishtp_set_client_data (hid_ishtp_cl , client_data );
773
- client_data -> hid_ishtp_cl = hid_ishtp_cl ;
738
+ ishtp_cl_destroy_connection (hid_ishtp_cl , true);
774
739
775
740
client_data -> num_hid_devices = 0 ;
776
741
777
742
for (retry = 0 ; retry < 3 ; ++ retry ) {
778
- rv = hid_ishtp_cl_init (hid_ishtp_cl , 1 );
743
+ rv = hid_ishtp_cl_init (hid_ishtp_cl , true );
779
744
if (!rv )
780
745
break ;
781
746
dev_err (cl_data_to_dev (client_data ), "Retry reset init\n" );
@@ -841,7 +806,7 @@ static int hid_ishtp_cl_probe(struct ishtp_cl_device *cl_device)
841
806
842
807
ishtp_hid_print_trace = ishtp_trace_callback (cl_device );
843
808
844
- rv = hid_ishtp_cl_init (hid_ishtp_cl , 0 );
809
+ rv = hid_ishtp_cl_init (hid_ishtp_cl , false );
845
810
if (rv ) {
846
811
ishtp_cl_free (hid_ishtp_cl );
847
812
return rv ;
@@ -868,11 +833,9 @@ static void hid_ishtp_cl_remove(struct ishtp_cl_device *cl_device)
868
833
hid_ishtp_cl );
869
834
870
835
dev_dbg (ishtp_device (cl_device ), "%s\n" , __func__ );
871
- ishtp_set_connection_state (hid_ishtp_cl , ISHTP_CL_DISCONNECTING );
872
- ishtp_cl_disconnect (hid_ishtp_cl );
836
+ hid_ishtp_cl_deinit (hid_ishtp_cl );
873
837
ishtp_put_device (cl_device );
874
838
ishtp_hid_remove (client_data );
875
- hid_ishtp_cl_deinit (hid_ishtp_cl );
876
839
877
840
hid_ishtp_cl = NULL ;
878
841
0 commit comments