Skip to content

Commit 09b57d9

Browse files
EvenxfJiri Kosina
authored andcommitted
HID: intel-ish-hid: ishtp-fw-loader: use helper functions for connection
Use helper functions ishtp_cl_establish_connection() and ishtp_cl_destroy_connection() to establish and destroy connection respectively. These functions are used during initialization, reset and deinitialization flows. No functional changes are expected. Signed-off-by: Even Xu <[email protected]> Acked-by: Srinivas Pandruvada <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent f645a90 commit 09b57d9

File tree

1 file changed

+12
-48
lines changed

1 file changed

+12
-48
lines changed

drivers/hid/intel-ish-hid/ishtp-fw-loader.c

Lines changed: 12 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -840,43 +840,22 @@ static void load_fw_from_host_handler(struct work_struct *work)
840840
*
841841
* Return: 0 for success, negative error code for failure
842842
*/
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)
844844
{
845845
int rv;
846-
struct ishtp_fw_client *fw_client;
847846
struct ishtp_cl_data *client_data =
848847
ishtp_get_client_data(loader_ishtp_cl);
849848

850849
dev_dbg(cl_data_to_dev(client_data), "reset flag: %d\n", reset);
851850

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);
877856
if (rv < 0) {
878857
dev_err(cl_data_to_dev(client_data), "Client connect fail\n");
879-
goto err_cl_unlink;
858+
goto err_cl_disconnect;
880859
}
881860

882861
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)
885864

886865
return 0;
887866

888-
err_cl_unlink:
889-
ishtp_cl_unlink(loader_ishtp_cl);
867+
err_cl_disconnect:
868+
ishtp_cl_destroy_connection(loader_ishtp_cl, reset);
890869
return rv;
891870
}
892871

893872
static void loader_deinit(struct ishtp_cl *loader_ishtp_cl)
894873
{
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);
899875

900876
/* Disband and free all Tx and Rx client-level rings */
901877
ishtp_cl_free(loader_ishtp_cl);
@@ -914,19 +890,7 @@ static void reset_handler(struct work_struct *work)
914890
loader_ishtp_cl = client_data->loader_ishtp_cl;
915891
cl_device = client_data->cl_device;
916892

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);
930894

931895
rv = loader_init(loader_ishtp_cl, 1);
932896
if (rv < 0) {
@@ -974,7 +938,7 @@ static int loader_ishtp_cl_probe(struct ishtp_cl_device *cl_device)
974938
INIT_WORK(&client_data->work_fw_load,
975939
load_fw_from_host_handler);
976940

977-
rv = loader_init(loader_ishtp_cl, 0);
941+
rv = loader_init(loader_ishtp_cl, false);
978942
if (rv < 0) {
979943
ishtp_cl_free(loader_ishtp_cl);
980944
return rv;

0 commit comments

Comments
 (0)