Input: vsxxxaa - change formatting style to match the rest of the kernel
- no spaces between function name and opening parenthesis - switch statements were indented too much This makes checkpatch (and me) happy. Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
This commit is contained in:
parent
7d3fadd148
commit
216023255a
|
@ -99,14 +99,15 @@ MODULE_LICENSE ("GPL");
|
|||
|
||||
#define VSXXXAA_INTRO_MASK 0x80
|
||||
#define VSXXXAA_INTRO_HEAD 0x80
|
||||
#define IS_HDR_BYTE(x) (((x) & VSXXXAA_INTRO_MASK) \
|
||||
== VSXXXAA_INTRO_HEAD)
|
||||
#define IS_HDR_BYTE(x) \
|
||||
(((x) & VSXXXAA_INTRO_MASK) == VSXXXAA_INTRO_HEAD)
|
||||
|
||||
#define VSXXXAA_PACKET_MASK 0xe0
|
||||
#define VSXXXAA_PACKET_REL 0x80
|
||||
#define VSXXXAA_PACKET_ABS 0xc0
|
||||
#define VSXXXAA_PACKET_POR 0xa0
|
||||
#define MATCH_PACKET_TYPE(data, type) (((data) & VSXXXAA_PACKET_MASK) == (type))
|
||||
#define MATCH_PACKET_TYPE(data, type) \
|
||||
(((data) & VSXXXAA_PACKET_MASK) == (type))
|
||||
|
||||
|
||||
|
||||
|
@ -123,32 +124,30 @@ struct vsxxxaa {
|
|||
char phys[32];
|
||||
};
|
||||
|
||||
static void
|
||||
vsxxxaa_drop_bytes (struct vsxxxaa *mouse, int num)
|
||||
static void vsxxxaa_drop_bytes(struct vsxxxaa *mouse, int num)
|
||||
{
|
||||
if (num >= mouse->count)
|
||||
if (num >= mouse->count) {
|
||||
mouse->count = 0;
|
||||
else {
|
||||
} else {
|
||||
memmove(mouse->buf, mouse->buf + num - 1, BUFLEN - num);
|
||||
mouse->count -= num;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
vsxxxaa_queue_byte (struct vsxxxaa *mouse, unsigned char byte)
|
||||
static void vsxxxaa_queue_byte(struct vsxxxaa *mouse, unsigned char byte)
|
||||
{
|
||||
if (mouse->count == BUFLEN) {
|
||||
printk(KERN_ERR "%s on %s: Dropping a byte of full buffer.\n",
|
||||
mouse->name, mouse->phys);
|
||||
vsxxxaa_drop_bytes(mouse, 1);
|
||||
}
|
||||
|
||||
DBG(KERN_INFO "Queueing byte 0x%02x\n", byte);
|
||||
|
||||
mouse->buf[mouse->count++] = byte;
|
||||
}
|
||||
|
||||
static void
|
||||
vsxxxaa_detection_done (struct vsxxxaa *mouse)
|
||||
static void vsxxxaa_detection_done(struct vsxxxaa *mouse)
|
||||
{
|
||||
switch (mouse->type) {
|
||||
case 0x02:
|
||||
|
@ -176,8 +175,7 @@ vsxxxaa_detection_done (struct vsxxxaa *mouse)
|
|||
/*
|
||||
* Returns number of bytes to be dropped, 0 if packet is okay.
|
||||
*/
|
||||
static int
|
||||
vsxxxaa_check_packet (struct vsxxxaa *mouse, int packet_len)
|
||||
static int vsxxxaa_check_packet(struct vsxxxaa *mouse, int packet_len)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -188,30 +186,27 @@ vsxxxaa_check_packet (struct vsxxxaa *mouse, int packet_len)
|
|||
}
|
||||
|
||||
/* Check all following bytes */
|
||||
if (packet_len > 1) {
|
||||
for (i = 1; i < packet_len; i++) {
|
||||
if (IS_HDR_BYTE(mouse->buf[i])) {
|
||||
printk (KERN_ERR "Need to drop %d bytes "
|
||||
"of a broken packet.\n",
|
||||
printk(KERN_ERR
|
||||
"Need to drop %d bytes of a broken packet.\n",
|
||||
i - 1);
|
||||
DBG(KERN_INFO "check: len=%d, b[%d]=0x%02x\n",
|
||||
packet_len, i, mouse->buf[i]);
|
||||
return i - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __inline__ int
|
||||
vsxxxaa_smells_like_packet (struct vsxxxaa *mouse, unsigned char type, size_t len)
|
||||
static inline int vsxxxaa_smells_like_packet(struct vsxxxaa *mouse,
|
||||
unsigned char type, size_t len)
|
||||
{
|
||||
return (mouse->count >= len) && MATCH_PACKET_TYPE (mouse->buf[0], type);
|
||||
return mouse->count >= len && MATCH_PACKET_TYPE(mouse->buf[0], type);
|
||||
}
|
||||
|
||||
static void
|
||||
vsxxxaa_handle_REL_packet (struct vsxxxaa *mouse)
|
||||
static void vsxxxaa_handle_REL_packet(struct vsxxxaa *mouse)
|
||||
{
|
||||
struct input_dev *dev = mouse->dev;
|
||||
unsigned char *buf = mouse->buf;
|
||||
|
@ -245,9 +240,9 @@ vsxxxaa_handle_REL_packet (struct vsxxxaa *mouse)
|
|||
* Get button state. It's the low three bits
|
||||
* (for three buttons) of byte 0.
|
||||
*/
|
||||
left = (buf[0] & 0x04)? 1: 0;
|
||||
middle = (buf[0] & 0x02)? 1: 0;
|
||||
right = (buf[0] & 0x01)? 1: 0;
|
||||
left = buf[0] & 0x04;
|
||||
middle = buf[0] & 0x02;
|
||||
right = buf[0] & 0x01;
|
||||
|
||||
vsxxxaa_drop_bytes(mouse, 3);
|
||||
|
||||
|
@ -267,8 +262,7 @@ vsxxxaa_handle_REL_packet (struct vsxxxaa *mouse)
|
|||
input_sync(dev);
|
||||
}
|
||||
|
||||
static void
|
||||
vsxxxaa_handle_ABS_packet (struct vsxxxaa *mouse)
|
||||
static void vsxxxaa_handle_ABS_packet(struct vsxxxaa *mouse)
|
||||
{
|
||||
struct input_dev *dev = mouse->dev;
|
||||
unsigned char *buf = mouse->buf;
|
||||
|
@ -296,10 +290,10 @@ vsxxxaa_handle_ABS_packet (struct vsxxxaa *mouse)
|
|||
/*
|
||||
* Get button state. It's bits <4..1> of byte 0.
|
||||
*/
|
||||
left = (buf[0] & 0x02)? 1: 0;
|
||||
middle = (buf[0] & 0x04)? 1: 0;
|
||||
right = (buf[0] & 0x08)? 1: 0;
|
||||
touch = (buf[0] & 0x10)? 1: 0;
|
||||
left = buf[0] & 0x02;
|
||||
middle = buf[0] & 0x04;
|
||||
right = buf[0] & 0x08;
|
||||
touch = buf[0] & 0x10;
|
||||
|
||||
vsxxxaa_drop_bytes(mouse, 5);
|
||||
|
||||
|
@ -320,8 +314,7 @@ vsxxxaa_handle_ABS_packet (struct vsxxxaa *mouse)
|
|||
input_sync(dev);
|
||||
}
|
||||
|
||||
static void
|
||||
vsxxxaa_handle_POR_packet (struct vsxxxaa *mouse)
|
||||
static void vsxxxaa_handle_POR_packet(struct vsxxxaa *mouse)
|
||||
{
|
||||
struct input_dev *dev = mouse->dev;
|
||||
unsigned char *buf = mouse->buf;
|
||||
|
@ -356,9 +349,9 @@ vsxxxaa_handle_POR_packet (struct vsxxxaa *mouse)
|
|||
* (for three buttons) of byte 0. Maybe even the bit <3>
|
||||
* has some meaning if a tablet is attached.
|
||||
*/
|
||||
left = (buf[0] & 0x04)? 1: 0;
|
||||
middle = (buf[0] & 0x02)? 1: 0;
|
||||
right = (buf[0] & 0x01)? 1: 0;
|
||||
left = buf[0] & 0x04;
|
||||
middle = buf[0] & 0x02;
|
||||
right = buf[0] & 0x01;
|
||||
|
||||
vsxxxaa_drop_bytes(mouse, 4);
|
||||
vsxxxaa_detection_done(mouse);
|
||||
|
@ -381,7 +374,8 @@ vsxxxaa_handle_POR_packet (struct vsxxxaa *mouse)
|
|||
* If the mouse was hot-plugged, we need to force differential mode
|
||||
* now... However, give it a second to recover from it's reset.
|
||||
*/
|
||||
printk (KERN_NOTICE "%s on %s: Forceing standard packet format, "
|
||||
printk(KERN_NOTICE
|
||||
"%s on %s: Forcing standard packet format, "
|
||||
"incremental streaming mode and 72 samples/sec\n",
|
||||
mouse->name, mouse->phys);
|
||||
serio_write(mouse->serio, 'S'); /* Standard format */
|
||||
|
@ -391,8 +385,7 @@ vsxxxaa_handle_POR_packet (struct vsxxxaa *mouse)
|
|||
serio_write(mouse->serio, 'L'); /* 72 samples/sec */
|
||||
}
|
||||
|
||||
static void
|
||||
vsxxxaa_parse_buffer (struct vsxxxaa *mouse)
|
||||
static void vsxxxaa_parse_buffer(struct vsxxxaa *mouse)
|
||||
{
|
||||
unsigned char *buf = mouse->buf;
|
||||
int stray_bytes;
|
||||
|
@ -422,51 +415,38 @@ vsxxxaa_parse_buffer (struct vsxxxaa *mouse)
|
|||
if (vsxxxaa_smells_like_packet(mouse, VSXXXAA_PACKET_REL, 3)) {
|
||||
/* Check for broken packet */
|
||||
stray_bytes = vsxxxaa_check_packet(mouse, 3);
|
||||
if (stray_bytes > 0) {
|
||||
printk (KERN_ERR "Dropping %d bytes now...\n",
|
||||
stray_bytes);
|
||||
vsxxxaa_drop_bytes (mouse, stray_bytes);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!stray_bytes)
|
||||
vsxxxaa_handle_REL_packet(mouse);
|
||||
continue; /* More to parse? */
|
||||
}
|
||||
|
||||
if (vsxxxaa_smells_like_packet (mouse, VSXXXAA_PACKET_ABS, 5)) {
|
||||
} else if (vsxxxaa_smells_like_packet(mouse,
|
||||
VSXXXAA_PACKET_ABS, 5)) {
|
||||
/* Check for broken packet */
|
||||
stray_bytes = vsxxxaa_check_packet(mouse, 5);
|
||||
if (stray_bytes > 0) {
|
||||
printk (KERN_ERR "Dropping %d bytes now...\n",
|
||||
stray_bytes);
|
||||
vsxxxaa_drop_bytes (mouse, stray_bytes);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!stray_bytes)
|
||||
vsxxxaa_handle_ABS_packet(mouse);
|
||||
continue; /* More to parse? */
|
||||
}
|
||||
|
||||
if (vsxxxaa_smells_like_packet (mouse, VSXXXAA_PACKET_POR, 4)) {
|
||||
} else if (vsxxxaa_smells_like_packet(mouse,
|
||||
VSXXXAA_PACKET_POR, 4)) {
|
||||
/* Check for broken packet */
|
||||
stray_bytes = vsxxxaa_check_packet(mouse, 4);
|
||||
if (!stray_bytes)
|
||||
vsxxxaa_handle_POR_packet(mouse);
|
||||
|
||||
} else {
|
||||
break; /* No REL, ABS or POR packet found */
|
||||
}
|
||||
|
||||
if (stray_bytes > 0) {
|
||||
printk(KERN_ERR "Dropping %d bytes now...\n",
|
||||
stray_bytes);
|
||||
vsxxxaa_drop_bytes(mouse, stray_bytes);
|
||||
continue;
|
||||
}
|
||||
|
||||
vsxxxaa_handle_POR_packet (mouse);
|
||||
continue; /* More to parse? */
|
||||
}
|
||||
|
||||
break; /* No REL, ABS or POR packet found */
|
||||
} while (1);
|
||||
}
|
||||
|
||||
static irqreturn_t
|
||||
vsxxxaa_interrupt (struct serio *serio, unsigned char data, unsigned int flags)
|
||||
static irqreturn_t vsxxxaa_interrupt(struct serio *serio,
|
||||
unsigned char data, unsigned int flags)
|
||||
{
|
||||
struct vsxxxaa *mouse = serio_get_drvdata(serio);
|
||||
|
||||
|
@ -476,8 +456,7 @@ vsxxxaa_interrupt (struct serio *serio, unsigned char data, unsigned int flags)
|
|||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static void
|
||||
vsxxxaa_disconnect (struct serio *serio)
|
||||
static void vsxxxaa_disconnect(struct serio *serio)
|
||||
{
|
||||
struct vsxxxaa *mouse = serio_get_drvdata(serio);
|
||||
|
||||
|
@ -487,8 +466,7 @@ vsxxxaa_disconnect (struct serio *serio)
|
|||
kfree(mouse);
|
||||
}
|
||||
|
||||
static int
|
||||
vsxxxaa_connect (struct serio *serio, struct serio_driver *drv)
|
||||
static int vsxxxaa_connect(struct serio *serio, struct serio_driver *drv)
|
||||
{
|
||||
struct vsxxxaa *mouse;
|
||||
struct input_dev *input_dev;
|
||||
|
@ -510,15 +488,15 @@ vsxxxaa_connect (struct serio *serio, struct serio_driver *drv)
|
|||
input_dev->id.bustype = BUS_RS232;
|
||||
input_dev->dev.parent = &serio->dev;
|
||||
|
||||
set_bit (EV_KEY, input_dev->evbit); /* We have buttons */
|
||||
set_bit (EV_REL, input_dev->evbit);
|
||||
set_bit (EV_ABS, input_dev->evbit);
|
||||
set_bit (BTN_LEFT, input_dev->keybit); /* We have 3 buttons */
|
||||
set_bit (BTN_MIDDLE, input_dev->keybit);
|
||||
set_bit (BTN_RIGHT, input_dev->keybit);
|
||||
set_bit (BTN_TOUCH, input_dev->keybit); /* ...and Tablet */
|
||||
set_bit (REL_X, input_dev->relbit);
|
||||
set_bit (REL_Y, input_dev->relbit);
|
||||
__set_bit(EV_KEY, input_dev->evbit); /* We have buttons */
|
||||
__set_bit(EV_REL, input_dev->evbit);
|
||||
__set_bit(EV_ABS, input_dev->evbit);
|
||||
__set_bit(BTN_LEFT, input_dev->keybit); /* We have 3 buttons */
|
||||
__set_bit(BTN_MIDDLE, input_dev->keybit);
|
||||
__set_bit(BTN_RIGHT, input_dev->keybit);
|
||||
__set_bit(BTN_TOUCH, input_dev->keybit); /* ...and Tablet */
|
||||
__set_bit(REL_X, input_dev->relbit);
|
||||
__set_bit(REL_Y, input_dev->relbit);
|
||||
input_set_abs_params(input_dev, ABS_X, 0, 1023, 0, 0);
|
||||
input_set_abs_params(input_dev, ABS_Y, 0, 1023, 0, 0);
|
||||
|
||||
|
@ -570,14 +548,12 @@ static struct serio_driver vsxxxaa_drv = {
|
|||
.disconnect = vsxxxaa_disconnect,
|
||||
};
|
||||
|
||||
static int __init
|
||||
vsxxxaa_init (void)
|
||||
static int __init vsxxxaa_init(void)
|
||||
{
|
||||
return serio_register_driver(&vsxxxaa_drv);
|
||||
}
|
||||
|
||||
static void __exit
|
||||
vsxxxaa_exit (void)
|
||||
static void __exit vsxxxaa_exit(void)
|
||||
{
|
||||
serio_unregister_driver(&vsxxxaa_drv);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue