[PATCH 8/8] Input: adi - clean up formatting

From: Dmitry Torokhov

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


Wrap the static capability and hat-mapping tables within 80 columns,
add missing blank lines between declarations, move assignments out of
conditionals, split single-line statements and chained assignments onto
separate lines, balance braces and remove redundant void return
statements, and fix switch, conditional, and error-label indentation.

No functional changes intended.

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

diff --git a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c
index 787af165db2a..9d461734a3d1 100644
--- a/drivers/input/joystick/adi.c
+++ b/drivers/input/joystick/adi.c
@@ -61,16 +61,46 @@ MODULE_LICENSE("GPL");
* Names, buttons, axes ...
*/

-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 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 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 };
+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 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;
@@ -109,7 +139,10 @@ static const struct adi_model adi_models[] = {
static struct {
int x;
int y;
-} adi_hat_to_axis[] = {{ 0, 0}, { 0,-1}, { 1,-1}, { 1, 0}, { 1, 1}, { 0, 1}, {-1, 1}, {-1, 0}, {-1,-1}};
+} adi_hat_to_axis[] = {
+ { 0, 0 }, { 0, -1 }, { 1, -1 }, { 1, 0 }, { 1, 1 },
+ { 0, 1 }, { -1, 1 }, { -1, 0 }, { -1, -1 }
+};

/*
* Per-port information.
@@ -178,14 +211,16 @@ static void adi_read_packet(struct adi_port *port)
adi[i].ret < ADI_MAX_LENGTH - 1 && t[i] > 0) {
adi[i].data[++adi[i].ret] = w;
t[i] = gameport_time(gameport, ADI_MAX_STROBE);
- } else t[i] = 0;
- } else if (!(x & ADI_STROBE_MASK)) s[i] = 1;
+ } else {
+ t[i] = 0;
+ }
+ } else if (!(x & ADI_STROBE_MASK)) {
+ s[i] = 1;
+ }
}
} while (t[0] > 0 || t[1] > 0);

local_irq_restore(flags);
-
- return;
}

/*
@@ -195,13 +230,16 @@ static void adi_read_packet(struct adi_port *port)

static void adi_move_bits(struct adi_port *port, int length)
{
- int i, offset;
struct adi *adi = port->adi;
+ int i, offset;

- adi[0].idx = adi[1].idx = 0;
+ adi[0].idx = 0;
+ adi[1].idx = 0;

- if (adi[0].ret <= 0 || adi[1].ret <= 0) return;
- if (adi[0].data[0] & ADI_DATA_BIT || !(adi[1].data[0] & ADI_DATA_BIT)) return;
+ if (adi[0].ret <= 0 || adi[1].ret <= 0)
+ return;
+ if (adi[0].data[0] & ADI_DATA_BIT || !(adi[1].data[0] & ADI_DATA_BIT))
+ return;

if (length <= 0)
goto err_out;
@@ -231,7 +269,11 @@ static inline int adi_get_bits(struct adi *adi, int count)
{
int bits = 0;
int i;
- if ((adi->idx += count) > adi->ret) return 0;
+
+ adi->idx += count;
+ if (adi->idx > adi->ret)
+ return 0;
+
for (i = 0; i < count; i++)
bits |= !!(adi->data[adi->idx - i] & ADI_DATA_BIT) << i;
return bits;
@@ -248,7 +290,8 @@ static int adi_decode(struct adi *adi)
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)))
+ if (adi->ret < adi->length ||
+ adi->id != (adi_get_bits(adi, 4) | (adi_get_bits(adi, 4) << 4)))
return -1;

for (i = 0; i < adi->axes10; i++)
@@ -267,7 +310,9 @@ static int adi_decode(struct adi *adi)
}

for (i = 0; i < adi->hats; i++) {
- if ((t = adi_get_bits(adi, 4)) > 8) t = 0;
+ t = adi_get_bits(adi, 4);
+ if (t > 8)
+ t = 0;
input_report_abs(dev, *abs++, adi_hat_to_axis[t].x);
input_report_abs(dev, *abs++, adi_hat_to_axis[t].y);
}
@@ -294,7 +339,7 @@ static int adi_read(struct adi_port *port)

for (i = 0; i < 2; i++)
if (port->adi[i].length)
- result |= adi_decode(port->adi + i);
+ result |= adi_decode(port->adi + i);

return result;
}
@@ -350,7 +395,7 @@ static void adi_init_digital(struct gameport *gameport)
msleep(seq[i]);
if (seq[i] < 0) {
mdelay(-seq[i]);
- udelay(-seq[i]*14); /* It looks like mdelay() is off by approx 1.4% */
+ udelay(-seq[i] * 14); /* It looks like mdelay() is off by approx 1.4% */
}
}
}
@@ -364,7 +409,8 @@ static void adi_id_decode(struct adi *adi, struct adi_port *port)
if (adi->ret < ADI_MIN_ID_LENGTH) /* Minimum ID packet length */
return;

- if (adi->ret < (t = adi_get_bits(adi, 10))) {
+ t = adi_get_bits(adi, 10);
+ if (adi->ret < t) {
dev_warn(dev, "Short ID packet: reported: %d != read: %d\n",
t, adi->ret);
return;
@@ -372,7 +418,9 @@ static void adi_id_decode(struct adi *adi, struct adi_port *port)

adi->id = adi_get_bits(adi, 4) | (adi_get_bits(adi, 4) << 4);

- if ((t = adi_get_bits(adi, 4)) & ADI_FLAG_HAT) adi->hats++;
+ t = adi_get_bits(adi, 4);
+ if (t & ADI_FLAG_HAT)
+ adi->hats++;

adi->length = adi_get_bits(adi, 10);

@@ -422,15 +470,15 @@ static void adi_id_decode(struct adi *adi, struct adi_port *port)
}

switch (adi->id) {
- case ADI_ID_TPD:
- adi->pad = 4;
- break;
- case ADI_ID_WGP:
- adi->pad = 0;
- break;
- default:
- adi->pad = -1;
- break;
+ case ADI_ID_TPD:
+ adi->pad = 4;
+ break;
+ case ADI_ID_WGP:
+ adi->pad = 0;
+ break;
+ default:
+ adi->pad = -1;
+ break;
}

if (adi->pad >= 0) {
@@ -461,9 +509,10 @@ static int adi_init_input(struct adi *adi, struct adi_port *port, int half)
struct input_dev *input_dev;
int i;

- adi->dev = input_dev = input_allocate_device();
+ input_dev = input_allocate_device();
if (!input_dev)
return -ENOMEM;
+ adi->dev = input_dev;

if (adi->model->name)
scnprintf(adi->name, sizeof(adi->name),
@@ -506,7 +555,6 @@ static void adi_init_center(struct adi *adi)
return;

for (i = 0; i < adi_num_axes(adi); i++) {
-
t = adi->model->abs[i];
x = input_abs_get_val(adi->dev, t);

@@ -585,16 +633,19 @@ static int adi_connect(struct gameport *gameport, struct gameport_driver *drv)

return 0;

- fail3: while (--i >= 0) {
+fail3:
+ while (--i >= 0) {
if (port->adi[i].length > 0) {
input_unregister_device(port->adi[i].dev);
port->adi[i].dev = NULL;
}
}
- fail2: for (i = 0; i < 2; i++)
+fail2:
+ for (i = 0; i < 2; i++)
input_free_device(port->adi[i].dev);
gameport_close(gameport);
- fail1: gameport_set_drvdata(gameport, NULL);
+fail1:
+ gameport_set_drvdata(gameport, NULL);
kfree(port);
return err;
}
--
2.56.1.839.g22a8290db9-goog