usb: hid: All hid_ops callbacks get device pointer.

This commit extends USB hid API callbacks by adding
'const struct device *dev' parameter. If the application
configured more than one HID device then it must specify
separate hid_ops for each device as its unable to determine
for which device the callback was called.

This patch makes it possible to have only one hid_ops within
the application and the application is aware for which device
the callback was called because of explicit device pointer.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
This commit is contained in:
Emil Obalski 2020-08-17 15:17:14 +02:00 committed by Carles Cufí
commit 0d8bd579a5
5 changed files with 43 additions and 30 deletions

View file

@ -57,11 +57,12 @@ struct usb_hid_descriptor {
/* Public headers */
typedef int (*hid_cb_t)(struct usb_setup_packet *setup, int32_t *len,
typedef int (*hid_cb_t)(const struct device *dev,
struct usb_setup_packet *setup, int32_t *len,
uint8_t **data);
typedef void (*hid_int_ready_callback)(void);
typedef void (*hid_protocol_cb_t)(uint8_t protocol);
typedef void (*hid_idle_cb_t)(uint16_t report_id);
typedef void (*hid_int_ready_callback)(const struct device *dev);
typedef void (*hid_protocol_cb_t)(const struct device *dev, uint8_t protocol);
typedef void (*hid_idle_cb_t)(const struct device *dev, uint16_t report_id);
struct hid_ops {
hid_cb_t get_report;