#include <linux/input/mt.h>
#define WAC_MSG_RETRIES 5
#define WAC_CMD_RETRIES 10
#define DEV_ATTR_RW_PERM (S_IRUGO | S_IWUSR | S_IWGRP)
#define DEV_ATTR_WO_PERM (S_IWUSR | S_IWGRP)
#define DEV_ATTR_RO_PERM (S_IRUSR | S_IRGRP)
static int wacom_get_report(struct hid_device *hdev, u8 type, u8 *buf,
size_t size, unsigned int retries)
retval = hid_hw_raw_request(hdev, buf[0], buf, size, type,
} while ((retval == -ETIMEDOUT || retval == -EAGAIN) && --retries);
hid_err(hdev, "wacom_get_report: ran out of retries "
"(last error = %d)\n", retval);
static int wacom_set_report(struct hid_device *hdev, u8 type, u8 *buf,
size_t size, unsigned int retries)
retval = hid_hw_raw_request(hdev, buf[0], buf, size, type,
} while ((retval == -ETIMEDOUT || retval == -EAGAIN) && --retries);
hid_err(hdev, "wacom_set_report: ran out of retries "
"(last error = %d)\n", retval);
static void wacom_wac_queue_insert(struct hid_device *hdev,
struct kfifo_rec_ptr_2 *fifo,
while (kfifo_avail(fifo) < size) {
hid_warn(hdev, "%s: kfifo has filled, starting to drop events\n", __func__);
kfifo_in(fifo, raw_data, size);
static void wacom_wac_queue_flush(struct hid_device *hdev,
struct kfifo_rec_ptr_2 *fifo)
while (!kfifo_is_empty(fifo)) {
u8 buf[WACOM_PKGLEN_MAX];
size = kfifo_out(fifo, buf, sizeof(buf));
err = hid_report_raw_event(hdev, HID_INPUT_REPORT, buf, size, false);
hid_warn(hdev, "%s: unable to flush event due to error %d\n",