diff --git a/hid-xpadneo/src/hid-xpadneo.c b/hid-xpadneo/src/hid-xpadneo.c index 3ec206dc..9d7c0843 100644 --- a/hid-xpadneo/src/hid-xpadneo.c +++ b/hid-xpadneo/src/hid-xpadneo.c @@ -1020,10 +1020,7 @@ static int xpadneo_event(struct hid_device *hdev, struct hid_field *field, return 0; keyboard_missing: - if ((xdata->missing_reported & XPADNEO_MISSING_KEYBOARD) == 0) { - xdata->missing_reported |= XPADNEO_MISSING_KEYBOARD; - hid_err(hdev, "keyboard not detected\n"); - } + xpadneo_core_missing(xdata, XPADNEO_MISSING_KEYBOARD); stop_processing: return 1; @@ -1035,10 +1032,7 @@ static int xpadneo_init_hw(struct hid_device *hdev) struct xpadneo_devdata *xdata = hid_get_drvdata(hdev); if (!xdata->gamepad) { - if ((xdata->missing_reported & XPADNEO_MISSING_GAMEPAD) == 0) { - xdata->missing_reported |= XPADNEO_MISSING_GAMEPAD; - hid_err(hdev, "gamepad not detected\n"); - } + xpadneo_core_missing(xdata, XPADNEO_MISSING_GAMEPAD); return -EINVAL; } diff --git a/hid-xpadneo/src/xpadneo.h b/hid-xpadneo/src/xpadneo.h index 727cbc5e..6df9e9f6 100644 --- a/hid-xpadneo/src/xpadneo.h +++ b/hid-xpadneo/src/xpadneo.h @@ -195,5 +195,6 @@ extern int xpadneo_init_consumer(struct xpadneo_devdata *); extern int xpadneo_init_keyboard(struct xpadneo_devdata *); extern int xpadneo_init_synthetic(struct xpadneo_devdata *, char *, struct input_dev **); extern void xpadneo_report(struct hid_device *, struct hid_report *); +extern void xpadneo_core_missing(struct xpadneo_devdata *, u32); #endif diff --git a/hid-xpadneo/src/xpadneo/core.c b/hid-xpadneo/src/xpadneo/core.c index a338edc5..51b061e9 100644 --- a/hid-xpadneo/src/xpadneo/core.c +++ b/hid-xpadneo/src/xpadneo/core.c @@ -55,3 +55,23 @@ extern void xpadneo_report(struct hid_device *hdev, struct hid_report *report) input_sync(xdata->keyboard); } } + +extern void xpadneo_core_missing(struct xpadneo_devdata *xdata, u32 flag) +{ + struct hid_device *hdev = xdata->hdev; + + if ((xdata->missing_reported & flag) == 0) { + xdata->missing_reported |= flag; + switch (flag) { + case XPADNEO_MISSING_GAMEPAD: + hid_err(hdev, "gamepad not detected\n"); + break; + case XPADNEO_MISSING_KEYBOARD: + hid_err(hdev, "keyboard not detected\n"); + break; + default: + hid_err(hdev, "unexpected subdevice missing: %d\n", flag); + } + } + +}