[PATCH 4/8] Input: adi - use explicit fixed-width types and const tables

From: Dmitry Torokhov

Date: Mon Nov 30 2026 - 00:43:01 EST


Use explicit fixed-width u8/s8 types for the wire-decoded fields and
packet buffer in struct adi so signedness does not depend on
architecture or compiler flags. Qualify the static input code tables
as const and use unsigned char and unsigned short for the tables and
corresponding model pointers.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
---
drivers/input/joystick/adi.c | 40 ++++++++++++++++++------------------
1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c
index 7eb193ca5390..a016a73cca27 100644
--- a/drivers/input/joystick/adi.c
+++ b/drivers/input/joystick/adi.c
@@ -58,21 +58,21 @@ MODULE_LICENSE("GPL");
* Names, buttons, axes ...
*/

-static char adi_wmgpe_abs[] = { ABS_X, ABS_Y, ABS_HAT0X, ABS_HAT0Y };
-static char adi_wmi_abs[] = { ABS_X, ABS_Y, ABS_THROTTLE, ABS_HAT0X, ABS_HAT0Y, ABS_HAT1X, ABS_HAT1Y, ABS_HAT2X, ABS_HAT2Y };
-static char adi_wmed3d_abs[] = { ABS_X, ABS_Y, ABS_THROTTLE, ABS_RZ, ABS_HAT0X, ABS_HAT0Y };
-static char adi_cm2_abs[] = { ABS_X, ABS_Y, ABS_Z, ABS_RX, ABS_RY, ABS_RZ };
-static char adi_wmf_abs[] = { ABS_WHEEL, ABS_GAS, ABS_BRAKE, ABS_HAT0X, ABS_HAT0Y, ABS_HAT1X, ABS_HAT1Y, ABS_HAT2X, ABS_HAT2Y };
+static const unsigned char adi_wmgpe_abs[] = { ABS_X, ABS_Y, ABS_HAT0X, ABS_HAT0Y };
+static const unsigned char adi_wmi_abs[] = { ABS_X, ABS_Y, ABS_THROTTLE, ABS_HAT0X, ABS_HAT0Y, ABS_HAT1X, ABS_HAT1Y, ABS_HAT2X, ABS_HAT2Y };
+static const unsigned char adi_wmed3d_abs[] = { ABS_X, ABS_Y, ABS_THROTTLE, ABS_RZ, ABS_HAT0X, ABS_HAT0Y };
+static const unsigned char adi_cm2_abs[] = { ABS_X, ABS_Y, ABS_Z, ABS_RX, ABS_RY, ABS_RZ };
+static const unsigned char adi_wmf_abs[] = { ABS_WHEEL, ABS_GAS, ABS_BRAKE, ABS_HAT0X, ABS_HAT0Y, ABS_HAT1X, ABS_HAT1Y, ABS_HAT2X, ABS_HAT2Y };

-static short adi_wmgpe_key[] = { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_TL, BTN_TR, BTN_START, BTN_MODE, BTN_SELECT };
-static short adi_wmi_key[] = { BTN_TRIGGER, BTN_TOP, BTN_THUMB, BTN_TOP2, BTN_BASE, BTN_BASE2, BTN_BASE3, BTN_BASE4, BTN_EXTRA };
-static short adi_wmed3d_key[] = { BTN_TRIGGER, BTN_THUMB, BTN_THUMB2, BTN_TOP, BTN_TOP2, BTN_BASE, BTN_BASE2 };
-static short adi_cm2_key[] = { BTN_1, BTN_2, BTN_3, BTN_4, BTN_5, BTN_6, BTN_7, BTN_8 };
+static const unsigned short adi_wmgpe_key[] = { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_TL, BTN_TR, BTN_START, BTN_MODE, BTN_SELECT };
+static const unsigned short adi_wmi_key[] = { BTN_TRIGGER, BTN_TOP, BTN_THUMB, BTN_TOP2, BTN_BASE, BTN_BASE2, BTN_BASE3, BTN_BASE4, BTN_EXTRA };
+static const unsigned short adi_wmed3d_key[] = { BTN_TRIGGER, BTN_THUMB, BTN_THUMB2, BTN_TOP, BTN_TOP2, BTN_BASE, BTN_BASE2 };
+static const unsigned short adi_cm2_key[] = { BTN_1, BTN_2, BTN_3, BTN_4, BTN_5, BTN_6, BTN_7, BTN_8 };

struct adi_model {
const char *name;
- const char *abs;
- const short *key;
+ const unsigned char *abs;
+ const unsigned short *key;
unsigned char num_abs;
unsigned char num_key;
};
@@ -117,17 +117,17 @@ struct adi {
int length;
int ret;
int idx;
- unsigned char id;
- char buttons;
- char axes10;
- char axes8;
- signed char pad;
- char hats;
+ u8 id;
+ u8 buttons;
+ u8 axes10;
+ u8 axes8;
+ s8 pad;
+ u8 hats;
const struct adi_model *model;
char name[ADI_MAX_NAME_LENGTH];
char cname[ADI_MAX_CNAME_LENGTH];
char phys[ADI_MAX_PHYS_LENGTH];
- unsigned char data[ADI_MAX_LENGTH];
+ u8 data[ADI_MAX_LENGTH];
};

struct adi_port {
@@ -241,8 +241,8 @@ static inline int adi_get_bits(struct adi *adi, int count)
static int adi_decode(struct adi *adi)
{
struct input_dev *dev = adi->dev;
- const char *abs = adi->model->abs;
- const short *key = adi->model->key;
+ const unsigned char *abs = adi->model->abs;
+ const unsigned short *key = adi->model->key;
int i, t;

if (adi->ret < adi->length || adi->id != (adi_get_bits(adi, 4) | (adi_get_bits(adi, 4) << 4)))
--
2.56.1.839.g22a8290db9-goog