@@ -367,55 +367,33 @@ static void ish_event_cb(struct ishtp_cl_device *cl_device)
367
367
/**
368
368
* cros_ish_init() - Init function for ISHTP client
369
369
* @cros_ish_cl: ISHTP client instance
370
+ * @reset: true if called from reset handler
370
371
*
371
372
* This function complete the initializtion of the client.
372
373
*
373
374
* Return: 0 for success, negative error code for failure.
374
375
*/
375
- static int cros_ish_init (struct ishtp_cl * cros_ish_cl )
376
+ static int cros_ish_init (struct ishtp_cl * cros_ish_cl , bool reset )
376
377
{
377
378
int rv ;
378
- struct ishtp_device * dev ;
379
- struct ishtp_fw_client * fw_client ;
380
379
struct ishtp_cl_data * client_data = ishtp_get_client_data (cros_ish_cl );
381
380
382
- rv = ishtp_cl_link (cros_ish_cl );
383
- if (rv ) {
384
- dev_err (cl_data_to_dev (client_data ),
385
- "ishtp_cl_link failed\n" );
386
- return rv ;
387
- }
388
-
389
- dev = ishtp_get_ishtp_device (cros_ish_cl );
390
-
391
- /* Connect to firmware client */
392
- ishtp_set_tx_ring_size (cros_ish_cl , CROS_ISH_CL_TX_RING_SIZE );
393
- ishtp_set_rx_ring_size (cros_ish_cl , CROS_ISH_CL_RX_RING_SIZE );
394
-
395
- fw_client = ishtp_fw_cl_get_client (dev , & cros_ec_ishtp_id_table [0 ].guid );
396
- if (!fw_client ) {
397
- dev_err (cl_data_to_dev (client_data ),
398
- "ish client uuid not found\n" );
399
- rv = - ENOENT ;
400
- goto err_cl_unlink ;
401
- }
402
-
403
- ishtp_cl_set_fw_client_id (cros_ish_cl ,
404
- ishtp_get_fw_client_id (fw_client ));
405
- ishtp_set_connection_state (cros_ish_cl , ISHTP_CL_CONNECTING );
406
-
407
- rv = ishtp_cl_connect (cros_ish_cl );
381
+ rv = ishtp_cl_establish_connection (cros_ish_cl ,
382
+ & cros_ec_ishtp_id_table [0 ].guid ,
383
+ CROS_ISH_CL_TX_RING_SIZE ,
384
+ CROS_ISH_CL_RX_RING_SIZE ,
385
+ reset );
408
386
if (rv ) {
409
387
dev_err (cl_data_to_dev (client_data ),
410
388
"client connect fail\n" );
411
- goto err_cl_unlink ;
389
+ goto err_cl_disconnect ;
412
390
}
413
391
414
392
ishtp_register_event_cb (client_data -> cl_device , ish_event_cb );
415
393
return 0 ;
416
394
417
- err_cl_unlink :
418
- ishtp_cl_unlink (cros_ish_cl );
395
+ err_cl_disconnect :
396
+ ishtp_cl_destroy_connection (cros_ish_cl , reset );
419
397
return rv ;
420
398
}
421
399
@@ -427,10 +405,7 @@ static int cros_ish_init(struct ishtp_cl *cros_ish_cl)
427
405
*/
428
406
static void cros_ish_deinit (struct ishtp_cl * cros_ish_cl )
429
407
{
430
- ishtp_set_connection_state (cros_ish_cl , ISHTP_CL_DISCONNECTING );
431
- ishtp_cl_disconnect (cros_ish_cl );
432
- ishtp_cl_unlink (cros_ish_cl );
433
- ishtp_cl_flush_queues (cros_ish_cl );
408
+ ishtp_cl_destroy_connection (cros_ish_cl , false);
434
409
435
410
/* Disband and free all Tx and Rx client-level rings */
436
411
ishtp_cl_free (cros_ish_cl );
@@ -592,34 +567,18 @@ static void reset_handler(struct work_struct *work)
592
567
int rv ;
593
568
struct device * dev ;
594
569
struct ishtp_cl * cros_ish_cl ;
595
- struct ishtp_cl_device * cl_device ;
596
570
struct ishtp_cl_data * client_data =
597
571
container_of (work , struct ishtp_cl_data , work_ishtp_reset );
598
572
599
573
/* Lock for reset to complete */
600
574
down_write (& init_lock );
601
575
602
576
cros_ish_cl = client_data -> cros_ish_cl ;
603
- cl_device = client_data -> cl_device ;
604
577
605
- /* Unlink, flush queues & start again */
606
- ishtp_cl_unlink (cros_ish_cl );
607
- ishtp_cl_flush_queues (cros_ish_cl );
608
- ishtp_cl_free (cros_ish_cl );
609
-
610
- cros_ish_cl = ishtp_cl_allocate (cl_device );
611
- if (!cros_ish_cl ) {
612
- up_write (& init_lock );
613
- return ;
614
- }
615
-
616
- ishtp_set_drvdata (cl_device , cros_ish_cl );
617
- ishtp_set_client_data (cros_ish_cl , client_data );
618
- client_data -> cros_ish_cl = cros_ish_cl ;
578
+ ishtp_cl_destroy_connection (cros_ish_cl , true);
619
579
620
- rv = cros_ish_init (cros_ish_cl );
580
+ rv = cros_ish_init (cros_ish_cl , true );
621
581
if (rv ) {
622
- ishtp_cl_free (cros_ish_cl );
623
582
dev_err (cl_data_to_dev (client_data ), "Reset Failed\n" );
624
583
up_write (& init_lock );
625
584
return ;
@@ -672,7 +631,7 @@ static int cros_ec_ishtp_probe(struct ishtp_cl_device *cl_device)
672
631
INIT_WORK (& client_data -> work_ec_evt ,
673
632
ish_evt_handler );
674
633
675
- rv = cros_ish_init (cros_ish_cl );
634
+ rv = cros_ish_init (cros_ish_cl , false );
676
635
if (rv )
677
636
goto end_ishtp_cl_init_error ;
678
637
@@ -690,10 +649,7 @@ static int cros_ec_ishtp_probe(struct ishtp_cl_device *cl_device)
690
649
return 0 ;
691
650
692
651
end_cros_ec_dev_init_error :
693
- ishtp_set_connection_state (cros_ish_cl , ISHTP_CL_DISCONNECTING );
694
- ishtp_cl_disconnect (cros_ish_cl );
695
- ishtp_cl_unlink (cros_ish_cl );
696
- ishtp_cl_flush_queues (cros_ish_cl );
652
+ ishtp_cl_destroy_connection (cros_ish_cl , false);
697
653
ishtp_put_device (cl_device );
698
654
end_ishtp_cl_init_error :
699
655
ishtp_cl_free (cros_ish_cl );
0 commit comments