HID: Intel-ish-hid: Ishtp: Add helper functions for client connection
authorEven Xu <even.xu@intel.com>
Tue, 5 Dec 2023 01:50:30 +0000 (09:50 +0800)
committerJiri Kosina <jkosina@suse.com>
Wed, 6 Dec 2023 10:33:45 +0000 (11:33 +0100)
commita3a44d2d3a5c5ff6e73c711db5b1911b5a676bb0
treeffbd5af230ba94a9e10c6addfb5051dc61b7af33
parent1f342790ad3c2456e15351829ad5d8919cccc03f
HID: Intel-ish-hid: Ishtp: Add helper functions for client connection

For every ishtp client driver during initialization state, the flow is:
1 - Allocate an ISHTP client instance
2 - Reserve a host id and link the client instance
3 - Search a firmware client using UUID and get related
    client information
4 - Bind firmware client id to the ISHTP client instance
5 - Set the state the ISHTP client instance to CONNECTING
6 - Send connect request to firmware
7 - Register event callback for messages from the firmware

During deinitizalization state, the flow is:
9 - Set the state the ISHTP client instance to ISHTP_CL_DISCONNECTING
10 - Issue disconnect request to firmware
11 - Unlike the client instance
12 - Flush message queue
13 - Free ISHTP client instance

Step 2-7 are identical to the steps of client driver initialization
and driver reset flow, but reallocation of the RX/TX ring buffers
can be avoided in reset flow.

Also for step 9-12, they are identical to the steps of client driver
failure handling after connect request, driver reset flow and
driver removing.

So, add two helper functions to simplify client driver code.
ishtp_cl_establish_connection()
ishtp_cl_destroy_connection()

No functional changes are expected.

Signed-off-by: Even Xu <even.xu@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
drivers/hid/intel-ish-hid/ishtp/client.c
include/linux/intel-ish-client-if.h