Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *  Copyright (c) 2001 Arndt Schoenewald
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *  Copyright (c) 2000-2001 Vojtech Pavlik
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *  Copyright (c) 2000 Mark Fletcher
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *  Sponsored by Quelltext AG (http://www.quelltext-ag.de), Dortmund, Germany
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * Driver to use Handykey's Twiddler (the first edition, i.e. the one with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * the RS232 interface) as a joystick under Linux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * The Twiddler is a one-handed chording keyboard featuring twelve buttons on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  * the front, six buttons on the top, and a built-in tilt sensor. The buttons
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * on the front, which are grouped as four rows of three buttons, are pressed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * by the four fingers (this implies only one button per row can be held down
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * at the same time) and the buttons on the top are for the thumb. The tilt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * sensor delivers X and Y axis data depending on how the Twiddler is held.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * Additional information can be found at http://www.handykey.com.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * This driver does not use the Twiddler for its intended purpose, i.e. as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * a chording keyboard, but as a joystick: pressing and releasing a button
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * immediately sends a corresponding button event, and tilting it generates
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * corresponding ABS_X and ABS_Y events. This turns the Twiddler into a game
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * controller with amazing 18 buttons :-)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * Note: The Twiddler2 (the successor of the Twiddler that connects directly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * to the PS/2 keyboard and mouse ports) is NOT supported by this driver!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * For questions or feedback regarding this driver module please contact:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  * Arndt Schoenewald <arndt@quelltext.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #include <linux/serio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #define DRIVER_DESC	"Handykey Twiddler keyboard as a joystick driver"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) MODULE_DESCRIPTION(DRIVER_DESC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  * Constants.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #define TWIDJOY_MAX_LENGTH 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) static struct twidjoy_button_spec {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	int bitshift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	int bitmask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	int buttons[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) twidjoy_buttons[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	{  0, 3, { BTN_A,      BTN_B,     BTN_C    } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	{  2, 3, { BTN_X,      BTN_Y,     BTN_Z    } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	{  4, 3, { BTN_TL,     BTN_TR,    BTN_TR2  } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	{  6, 3, { BTN_SELECT, BTN_START, BTN_MODE } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	{  8, 1, { BTN_BASE5                       } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	{  9, 1, { BTN_BASE                        } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	{ 10, 1, { BTN_BASE3                       } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	{ 11, 1, { BTN_BASE4                       } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	{ 12, 1, { BTN_BASE2                       } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	{ 13, 1, { BTN_BASE6                       } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	{ 0,  0, { 0                               } }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  * Per-Twiddler data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) struct twidjoy {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	struct input_dev *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	int idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	unsigned char data[TWIDJOY_MAX_LENGTH];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	char phys[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)  * twidjoy_process_packet() decodes packets the driver receives from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)  * Twiddler. It updates the data accordingly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) static void twidjoy_process_packet(struct twidjoy *twidjoy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	struct input_dev *dev = twidjoy->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	unsigned char *data = twidjoy->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	struct twidjoy_button_spec *bp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	int button_bits, abs_x, abs_y;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	button_bits = ((data[1] & 0x7f) << 7) | (data[0] & 0x7f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	for (bp = twidjoy_buttons; bp->bitmask; bp++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		int value = (button_bits & (bp->bitmask << bp->bitshift)) >> bp->bitshift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		for (i = 0; i < bp->bitmask; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 			input_report_key(dev, bp->buttons[i], i+1 == value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	abs_x = ((data[4] & 0x07) << 5) | ((data[3] & 0x7C) >> 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	if (data[4] & 0x08) abs_x -= 256;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	abs_y = ((data[3] & 0x01) << 7) | ((data[2] & 0x7F) >> 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	if (data[3] & 0x02) abs_y -= 256;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	input_report_abs(dev, ABS_X, -abs_x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	input_report_abs(dev, ABS_Y, +abs_y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	input_sync(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)  * twidjoy_interrupt() is called by the low level driver when characters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)  * are ready for us. We then buffer them for further processing, or call the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)  * packet processing routine.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) static irqreturn_t twidjoy_interrupt(struct serio *serio, unsigned char data, unsigned int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	struct twidjoy *twidjoy = serio_get_drvdata(serio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	/* All Twiddler packets are 5 bytes. The fact that the first byte
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	 * has a MSB of 0 and all other bytes have a MSB of 1 can be used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	 * to check and regain sync. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	if ((data & 0x80) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		twidjoy->idx = 0;	/* this byte starts a new packet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	else if (twidjoy->idx == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		return IRQ_HANDLED;	/* wrong MSB -- ignore this byte */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	if (twidjoy->idx < TWIDJOY_MAX_LENGTH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		twidjoy->data[twidjoy->idx++] = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	if (twidjoy->idx == TWIDJOY_MAX_LENGTH) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		twidjoy_process_packet(twidjoy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		twidjoy->idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)  * twidjoy_disconnect() is the opposite of twidjoy_connect()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) static void twidjoy_disconnect(struct serio *serio)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	struct twidjoy *twidjoy = serio_get_drvdata(serio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	serio_close(serio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	serio_set_drvdata(serio, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	input_unregister_device(twidjoy->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	kfree(twidjoy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)  * twidjoy_connect() is the routine that is called when someone adds a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)  * new serio device. It looks for the Twiddler, and if found, registers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)  * it as an input device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) static int twidjoy_connect(struct serio *serio, struct serio_driver *drv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	struct twidjoy_button_spec *bp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	struct twidjoy *twidjoy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	struct input_dev *input_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	int err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	twidjoy = kzalloc(sizeof(struct twidjoy), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	input_dev = input_allocate_device();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	if (!twidjoy || !input_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		goto fail1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	twidjoy->dev = input_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	snprintf(twidjoy->phys, sizeof(twidjoy->phys), "%s/input0", serio->phys);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	input_dev->name = "Handykey Twiddler";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	input_dev->phys = twidjoy->phys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	input_dev->id.bustype = BUS_RS232;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	input_dev->id.vendor = SERIO_TWIDJOY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	input_dev->id.product = 0x0001;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	input_dev->id.version = 0x0100;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	input_dev->dev.parent = &serio->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	input_set_abs_params(input_dev, ABS_X, -50, 50, 4, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	input_set_abs_params(input_dev, ABS_Y, -50, 50, 4, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	for (bp = twidjoy_buttons; bp->bitmask; bp++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		for (i = 0; i < bp->bitmask; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 			set_bit(bp->buttons[i], input_dev->keybit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	serio_set_drvdata(serio, twidjoy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	err = serio_open(serio, drv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 		goto fail2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	err = input_register_device(twidjoy->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		goto fail3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)  fail3:	serio_close(serio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)  fail2:	serio_set_drvdata(serio, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)  fail1:	input_free_device(input_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	kfree(twidjoy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)  * The serio driver structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) static const struct serio_device_id twidjoy_serio_ids[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		.type	= SERIO_RS232,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		.proto	= SERIO_TWIDJOY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		.id	= SERIO_ANY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		.extra	= SERIO_ANY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	{ 0 }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) MODULE_DEVICE_TABLE(serio, twidjoy_serio_ids);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) static struct serio_driver twidjoy_drv = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	.driver		= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		.name	= "twidjoy",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	.description	= DRIVER_DESC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	.id_table	= twidjoy_serio_ids,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	.interrupt	= twidjoy_interrupt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	.connect	= twidjoy_connect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	.disconnect	= twidjoy_disconnect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) module_serio_driver(twidjoy_drv);