Merge tag 'v4.17-rc6' into next
[sfrench/cifs-2.6.git] / drivers / input / joystick / xpad.c
index 06e9650b3b302f12394b9d92572afe872bae6da3..f5d2b5147dd44dbe348438c5cec599a2038993e8 100644 (file)
 
 #define XPAD_PKT_LEN 64
 
-/* xbox d-pads should map to buttons, as is required for DDR pads
-   but we map them to axes when possible to simplify things */
+/*
+ * xbox d-pads should map to buttons, as is required for DDR pads
+ * but we map them to axes when possible to simplify things
+ */
 #define MAP_DPAD_TO_BUTTONS            (1 << 0)
 #define MAP_TRIGGERS_TO_BUTTONS                (1 << 1)
 #define MAP_STICKS_TO_NULL             (1 << 2)
@@ -387,15 +389,15 @@ static const signed short xpad_abs_triggers[] = {
  * match against vendor id as well. Wired Xbox 360 devices have protocol 1,
  * wireless controllers have protocol 129.
  */
-#define XPAD_XBOX360_VENDOR_PROTOCOL(vend,pr) \
+#define XPAD_XBOX360_VENDOR_PROTOCOL(vend, pr) \
        .match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO, \
        .idVendor = (vend), \
        .bInterfaceClass = USB_CLASS_VENDOR_SPEC, \
        .bInterfaceSubClass = 93, \
        .bInterfaceProtocol = (pr)
 #define XPAD_XBOX360_VENDOR(vend) \
-       { XPAD_XBOX360_VENDOR_PROTOCOL(vend,1) }, \
-       { XPAD_XBOX360_VENDOR_PROTOCOL(vend,129) }
+       { XPAD_XBOX360_VENDOR_PROTOCOL((vend), 1) }, \
+       { XPAD_XBOX360_VENDOR_PROTOCOL((vend), 129) }
 
 /* The Xbox One controller uses subclass 71 and protocol 208. */
 #define XPAD_XBOXONE_VENDOR_PROTOCOL(vend, pr) \
@@ -405,7 +407,7 @@ static const signed short xpad_abs_triggers[] = {
        .bInterfaceSubClass = 71, \
        .bInterfaceProtocol = (pr)
 #define XPAD_XBOXONE_VENDOR(vend) \
-       { XPAD_XBOXONE_VENDOR_PROTOCOL(vend, 208) }
+       { XPAD_XBOXONE_VENDOR_PROTOCOL((vend), 208) }
 
 static const struct usb_device_id xpad_table[] = {
        { USB_INTERFACE_INFO('X', 'B', 0) },    /* X-Box USB-IF not approved class */
@@ -1573,7 +1575,6 @@ static void xpad_close(struct input_dev *dev)
 static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs)
 {
        struct usb_xpad *xpad = input_get_drvdata(input_dev);
-       set_bit(abs, input_dev->absbit);
 
        switch (abs) {
        case ABS_X:
@@ -1593,6 +1594,9 @@ static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs)
        case ABS_HAT0Y: /* the d-pad (only if dpad is mapped to axes */
                input_set_abs_params(input_dev, abs, -1, 1, 0, 0);
                break;
+       default:
+               input_set_abs_params(input_dev, abs, 0, 0, 0, 0);
+               break;
        }
 }
 
@@ -1633,10 +1637,7 @@ static int xpad_init_input(struct usb_xpad *xpad)
                input_dev->close = xpad_close;
        }
 
-       __set_bit(EV_KEY, input_dev->evbit);
-
        if (!(xpad->mapping & MAP_STICKS_TO_NULL)) {
-               __set_bit(EV_ABS, input_dev->evbit);
                /* set up axes */
                for (i = 0; xpad_abs[i] >= 0; i++)
                        xpad_set_up_abs(input_dev, xpad_abs[i]);
@@ -1644,21 +1645,22 @@ static int xpad_init_input(struct usb_xpad *xpad)
 
        /* set up standard buttons */
        for (i = 0; xpad_common_btn[i] >= 0; i++)
-               __set_bit(xpad_common_btn[i], input_dev->keybit);
+               input_set_capability(input_dev, EV_KEY, xpad_common_btn[i]);
 
        /* set up model-specific ones */
        if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W ||
            xpad->xtype == XTYPE_XBOXONE) {
                for (i = 0; xpad360_btn[i] >= 0; i++)
-                       __set_bit(xpad360_btn[i], input_dev->keybit);
+                       input_set_capability(input_dev, EV_KEY, xpad360_btn[i]);
        } else {
                for (i = 0; xpad_btn[i] >= 0; i++)
-                       __set_bit(xpad_btn[i], input_dev->keybit);
+                       input_set_capability(input_dev, EV_KEY, xpad_btn[i]);
        }
 
        if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
                for (i = 0; xpad_btn_pad[i] >= 0; i++)
-                       __set_bit(xpad_btn_pad[i], input_dev->keybit);
+                       input_set_capability(input_dev, EV_KEY,
+                                            xpad_btn_pad[i]);
        }
 
        /*
@@ -1675,7 +1677,8 @@ static int xpad_init_input(struct usb_xpad *xpad)
 
        if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) {
                for (i = 0; xpad_btn_triggers[i] >= 0; i++)
-                       __set_bit(xpad_btn_triggers[i], input_dev->keybit);
+                       input_set_capability(input_dev, EV_KEY,
+                                            xpad_btn_triggers[i]);
        } else {
                for (i = 0; xpad_abs_triggers[i] >= 0; i++)
                        xpad_set_up_abs(input_dev, xpad_abs_triggers[i]);