Move the interface functions in client.h to common include. These are already abstracted well to use as is. Also move any associated structures used by these functions.
Unified · Split
| @@ -19,15 +19,6 @@ · 18 unmodified lines | |||
| 19 | #include <linux/types.h> | 19 | #include <linux/types.h> |
| 20 | #include "ishtp-dev.h" | 20 | #include "ishtp-dev.h" |
| 21 | 21 | ||
| 22 | /* Client state */ | ||
| 23 | enum cl_state { | ||
| 24 | ISHTP_CL_INITIALIZING = 0, | ||
| 25 | ISHTP_CL_CONNECTING, | ||
| 26 | ISHTP_CL_CONNECTED, | ||
| 27 | ISHTP_CL_DISCONNECTING, | ||
| 28 | ISHTP_CL_DISCONNECTED | ||
| 29 | }; | ||
| 30 | |||
| 31 | /* Tx and Rx ring size */ | 22 | /* Tx and Rx ring size */ |
| 32 | #define CL_DEF_RX_RING_SIZE 2 | 23 | #define CL_DEF_RX_RING_SIZE 2 |
| 33 | #define CL_DEF_TX_RING_SIZE 2 | 24 | #define CL_DEF_TX_RING_SIZE 2 |
| @@ -169,19 +160,4 @@ static inline bool ishtp_cl_cmp_id(const struct ishtp_cl *cl1, · 135 unmodified lines | |||
| 169 | (cl1->fw_client_id == cl2->fw_client_id); | 160 | (cl1->fw_client_id == cl2->fw_client_id); |
| 170 | } | 161 | } |
| 171 | 162 | ||
| 172 | /* exported functions from ISHTP under client management scope */ | ||
| 173 | struct ishtp_cl *ishtp_cl_allocate(struct ishtp_cl_device *cl_device); | ||
| 174 | void ishtp_cl_free(struct ishtp_cl *cl); | ||
| 175 | int ishtp_cl_link(struct ishtp_cl *cl); | ||
| 176 | void ishtp_cl_unlink(struct ishtp_cl *cl); | ||
| 177 | int ishtp_cl_disconnect(struct ishtp_cl *cl); | ||
| 178 | int ishtp_cl_connect(struct ishtp_cl *cl); | ||
| 179 | int ishtp_cl_send(struct ishtp_cl *cl, uint8_t *buf, size_t length); | ||
| 180 | int ishtp_cl_flush_queues(struct ishtp_cl *cl); | ||
| 181 | |||
| 182 | /* exported functions from ISHTP client buffer management scope */ | ||
| 183 | int ishtp_cl_io_rb_recycle(struct ishtp_cl_rb *rb); | ||
| 184 | bool ishtp_cl_tx_empty(struct ishtp_cl *cl); | ||
| 185 | struct ishtp_cl_rb *ishtp_cl_rx_get_rb(struct ishtp_cl *cl); | ||
| 186 | |||
| 187 | #endif /* _ISHTP_CLIENT_H_ */ | 163 | #endif /* _ISHTP_CLIENT_H_ */ |
| @@ -79,32 +79,6 @@ struct ishtp_fw_client { · 78 unmodified lines | |||
| 79 | uint8_t client_id; | 79 | uint8_t client_id; |
| 80 | }; | 80 | }; |
| 81 | 81 | ||
| 82 | /** | ||
| 83 | * struct ishtp_msg_data - ISHTP message data struct | ||
| 84 | * @size: Size of data in the *data | ||
| 85 | * @data: Pointer to data | ||
| 86 | */ | ||
| 87 | struct ishtp_msg_data { | ||
| 88 | uint32_t size; | ||
| 89 | unsigned char *data; | ||
| 90 | }; | ||
| 91 | |||
| 92 | /* | ||
| 93 | * struct ishtp_cl_rb - request block structure | ||
| 94 | * @list: Link to list members | ||
| 95 | * @cl: ISHTP client instance | ||
| 96 | * @buffer: message header | ||
| 97 | * @buf_idx: Index into buffer | ||
| 98 | * @read_time: unused at this time | ||
| 99 | */ | ||
| 100 | struct ishtp_cl_rb { | ||
| 101 | struct list_head list; | ||
| 102 | struct ishtp_cl *cl; | ||
| 103 | struct ishtp_msg_data buffer; | ||
| 104 | unsigned long buf_idx; | ||
| 105 | unsigned long read_time; | ||
| 106 | }; | ||
| 107 | |||
| 108 | /* | 82 | /* |
| 109 | * Control info for IPC messages ISHTP/IPC sending FIFO - | 83 | * Control info for IPC messages ISHTP/IPC sending FIFO - |
| 110 | * list with inline data buffer | 84 | * list with inline data buffer |
| @@ -9,6 +9,16 @@ · 8 unmodified lines | |||
| 9 | #define _INTEL_ISH_CLIENT_IF_H_ | 9 | #define _INTEL_ISH_CLIENT_IF_H_ |
| 10 | 10 | ||
| 11 | struct ishtp_cl_device; | 11 | struct ishtp_cl_device; |
| 12 | struct ishtp_cl; | ||
| 13 | |||
| 14 | /* Client state */ | ||
| 15 | enum cl_state { | ||
| 16 | ISHTP_CL_INITIALIZING = 0, | ||
| 17 | ISHTP_CL_CONNECTING, | ||
| 18 | ISHTP_CL_CONNECTED, | ||
| 19 | ISHTP_CL_DISCONNECTING, | ||
| 20 | ISHTP_CL_DISCONNECTED | ||
| 21 | }; | ||
| 12 | 22 | ||
| 13 | /** | 23 | /** |
| 14 | * struct ishtp_cl_device - ISHTP device handle | 24 | * struct ishtp_cl_device - ISHTP device handle |
| @@ -29,6 +39,32 @@ struct ishtp_cl_driver { · 14 unmodified lines | |||
| 29 | const struct dev_pm_ops *pm; | 39 | const struct dev_pm_ops *pm; |
| 30 | }; | 40 | }; |
| 31 | 41 | ||
| 42 | /** | ||
| 43 | * struct ishtp_msg_data - ISHTP message data struct | ||
| 44 | * @size: Size of data in the *data | ||
| 45 | * @data: Pointer to data | ||
| 46 | */ | ||
| 47 | struct ishtp_msg_data { | ||
| 48 | uint32_t size; | ||
| 49 | unsigned char *data; | ||
| 50 | }; | ||
| 51 | |||
| 52 | /* | ||
| 53 | * struct ishtp_cl_rb - request block structure | ||
| 54 | * @list: Link to list members | ||
| 55 | * @cl: ISHTP client instance | ||
| 56 | * @buffer: message header | ||
| 57 | * @buf_idx: Index into buffer | ||
| 58 | * @read_time: unused at this time | ||
| 59 | */ | ||
| 60 | struct ishtp_cl_rb { | ||
| 61 | struct list_head list; | ||
| 62 | struct ishtp_cl *cl; | ||
| 63 | struct ishtp_msg_data buffer; | ||
| 64 | unsigned long buf_idx; | ||
| 65 | unsigned long read_time; | ||
| 66 | }; | ||
| 67 | |||
| 32 | int ishtp_cl_driver_register(struct ishtp_cl_driver *driver, | 68 | int ishtp_cl_driver_register(struct ishtp_cl_driver *driver, |
| 33 | struct module *owner); | 69 | struct module *owner); |
| 34 | void ishtp_cl_driver_unregister(struct ishtp_cl_driver *driver); | 70 | void ishtp_cl_driver_unregister(struct ishtp_cl_driver *driver); |
| @@ -40,4 +76,16 @@ struct device *ishtp_device(struct ishtp_cl_device *cl_device); · 5 unmodified lines | |||
| 40 | /* Trace interface for clients */ | 76 | /* Trace interface for clients */ |
| 41 | void *ishtp_trace_callback(struct ishtp_cl_device *cl_device); | 77 | void *ishtp_trace_callback(struct ishtp_cl_device *cl_device); |
| 42 | 78 | ||
| 79 | struct ishtp_cl *ishtp_cl_allocate(struct ishtp_cl_device *cl_device); | ||
| 80 | void ishtp_cl_free(struct ishtp_cl *cl); | ||
| 81 | int ishtp_cl_link(struct ishtp_cl *cl); | ||
| 82 | void ishtp_cl_unlink(struct ishtp_cl *cl); | ||
| 83 | int ishtp_cl_disconnect(struct ishtp_cl *cl); | ||
| 84 | int ishtp_cl_connect(struct ishtp_cl *cl); | ||
| 85 | int ishtp_cl_send(struct ishtp_cl *cl, uint8_t *buf, size_t length); | ||
| 86 | int ishtp_cl_flush_queues(struct ishtp_cl *cl); | ||
| 87 | int ishtp_cl_io_rb_recycle(struct ishtp_cl_rb *rb); | ||
| 88 | bool ishtp_cl_tx_empty(struct ishtp_cl *cl); | ||
| 89 | struct ishtp_cl_rb *ishtp_cl_rx_get_rb(struct ishtp_cl *cl); | ||
| 90 | |||
| 43 | #endif /* _INTEL_ISH_CLIENT_IF_H_ */ | 91 | #endif /* _INTEL_ISH_CLIENT_IF_H_ */ |