Commit 880d29f1 authored by Jiri Slaby's avatar Jiri Slaby Committed by Jiri Kosina

HID: indent switches/cases

Bring switch and cases into coding style and save thus some
indentation to make the code tighter.
Signed-off-by: default avatarJiri Slaby <jirislaby@gmail.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 02ae9a1a
...@@ -294,7 +294,6 @@ static s32 item_sdata(struct hid_item *item) ...@@ -294,7 +294,6 @@ static s32 item_sdata(struct hid_item *item)
static int hid_parser_global(struct hid_parser *parser, struct hid_item *item) static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
{ {
switch (item->tag) { switch (item->tag) {
case HID_GLOBAL_ITEM_TAG_PUSH: case HID_GLOBAL_ITEM_TAG_PUSH:
if (parser->global_stack_ptr == HID_GLOBAL_STACK_SIZE) { if (parser->global_stack_ptr == HID_GLOBAL_STACK_SIZE) {
...@@ -313,8 +312,8 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item) ...@@ -313,8 +312,8 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
return -1; return -1;
} }
memcpy(&parser->global, parser->global_stack + --parser->global_stack_ptr, memcpy(&parser->global, parser->global_stack +
sizeof(struct hid_global)); --parser->global_stack_ptr, sizeof(struct hid_global));
return 0; return 0;
case HID_GLOBAL_ITEM_TAG_USAGE_PAGE: case HID_GLOBAL_ITEM_TAG_USAGE_PAGE:
...@@ -352,21 +351,26 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item) ...@@ -352,21 +351,26 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
return 0; return 0;
case HID_GLOBAL_ITEM_TAG_REPORT_SIZE: case HID_GLOBAL_ITEM_TAG_REPORT_SIZE:
if ((parser->global.report_size = item_udata(item)) > 32) { parser->global.report_size = item_udata(item);
dbg_hid("invalid report_size %d\n", parser->global.report_size); if (parser->global.report_size > 32) {
dbg_hid("invalid report_size %d\n",
parser->global.report_size);
return -1; return -1;
} }
return 0; return 0;
case HID_GLOBAL_ITEM_TAG_REPORT_COUNT: case HID_GLOBAL_ITEM_TAG_REPORT_COUNT:
if ((parser->global.report_count = item_udata(item)) > HID_MAX_USAGES) { parser->global.report_count = item_udata(item);
dbg_hid("invalid report_count %d\n", parser->global.report_count); if (parser->global.report_count > HID_MAX_USAGES) {
dbg_hid("invalid report_count %d\n",
parser->global.report_count);
return -1; return -1;
} }
return 0; return 0;
case HID_GLOBAL_ITEM_TAG_REPORT_ID: case HID_GLOBAL_ITEM_TAG_REPORT_ID:
if ((parser->global.report_id = item_udata(item)) == 0) { parser->global.report_id = item_udata(item);
if (parser->global.report_id == 0) {
dbg_hid("report_id 0 is invalid\n"); dbg_hid("report_id 0 is invalid\n");
return -1; return -1;
} }
...@@ -395,7 +399,6 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item) ...@@ -395,7 +399,6 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
data = item_udata(item); data = item_udata(item);
switch (item->tag) { switch (item->tag) {
case HID_LOCAL_ITEM_TAG_DELIMITER: case HID_LOCAL_ITEM_TAG_DELIMITER:
if (data) { if (data) {
...@@ -595,7 +598,6 @@ static u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item) ...@@ -595,7 +598,6 @@ static u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item)
item->size = b & 3; item->size = b & 3;
switch (item->size) { switch (item->size) {
case 0: case 0:
return start; return start;
......
...@@ -188,12 +188,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel ...@@ -188,12 +188,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
} }
switch (usage->hid & HID_USAGE_PAGE) { switch (usage->hid & HID_USAGE_PAGE) {
case HID_UP_UNDEFINED: case HID_UP_UNDEFINED:
goto ignore; goto ignore;
case HID_UP_KEYBOARD: case HID_UP_KEYBOARD:
set_bit(EV_REP, input->evbit); set_bit(EV_REP, input->evbit);
if ((usage->hid & HID_USAGE) < 256) { if ((usage->hid & HID_USAGE) < 256) {
...@@ -205,7 +203,6 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel ...@@ -205,7 +203,6 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
break; break;
case HID_UP_BUTTON: case HID_UP_BUTTON:
code = ((usage->hid - 1) & 0xf); code = ((usage->hid - 1) & 0xf);
switch (field->application) { switch (field->application) {
...@@ -226,9 +223,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel ...@@ -226,9 +223,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
map_key(code); map_key(code);
break; break;
case HID_UP_SIMULATION: case HID_UP_SIMULATION:
switch (usage->hid & 0xffff) { switch (usage->hid & 0xffff) {
case 0xba: map_abs(ABS_RUDDER); break; case 0xba: map_abs(ABS_RUDDER); break;
case 0xbb: map_abs(ABS_THROTTLE); break; case 0xbb: map_abs(ABS_THROTTLE); break;
...@@ -240,7 +235,6 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel ...@@ -240,7 +235,6 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
break; break;
case HID_UP_GENDESK: case HID_UP_GENDESK:
if ((usage->hid & 0xf0) == 0x80) { /* SystemControl */ if ((usage->hid & 0xf0) == 0x80) { /* SystemControl */
switch (usage->hid & 0xf) { switch (usage->hid & 0xf) {
case 0x1: map_key_clear(KEY_POWER); break; case 0x1: map_key_clear(KEY_POWER); break;
...@@ -268,7 +262,6 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel ...@@ -268,7 +262,6 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
} }
switch (usage->hid) { switch (usage->hid) {
/* These usage IDs map directly to the usage codes. */ /* These usage IDs map directly to the usage codes. */
case HID_GD_X: case HID_GD_Y: case HID_GD_Z: case HID_GD_X: case HID_GD_Y: case HID_GD_Z:
case HID_GD_RX: case HID_GD_RY: case HID_GD_RZ: case HID_GD_RX: case HID_GD_RY: case HID_GD_RZ:
...@@ -294,7 +287,6 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel ...@@ -294,7 +287,6 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
break; break;
case HID_UP_LED: case HID_UP_LED:
switch (usage->hid & 0xffff) { /* HID-Value: */ switch (usage->hid & 0xffff) { /* HID-Value: */
case 0x01: map_led (LED_NUML); break; /* "Num Lock" */ case 0x01: map_led (LED_NUML); break; /* "Num Lock" */
case 0x02: map_led (LED_CAPSL); break; /* "Caps Lock" */ case 0x02: map_led (LED_CAPSL); break; /* "Caps Lock" */
...@@ -313,16 +305,13 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel ...@@ -313,16 +305,13 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
break; break;
case HID_UP_DIGITIZER: case HID_UP_DIGITIZER:
switch (usage->hid & 0xff) { switch (usage->hid & 0xff) {
case 0x30: /* TipPressure */ case 0x30: /* TipPressure */
if (!test_bit(BTN_TOUCH, input->keybit)) { if (!test_bit(BTN_TOUCH, input->keybit)) {
device->quirks |= HID_QUIRK_NOTOUCH; device->quirks |= HID_QUIRK_NOTOUCH;
set_bit(EV_KEY, input->evbit); set_bit(EV_KEY, input->evbit);
set_bit(BTN_TOUCH, input->keybit); set_bit(BTN_TOUCH, input->keybit);
} }
map_abs_clear(ABS_PRESSURE); map_abs_clear(ABS_PRESSURE);
break; break;
...@@ -354,7 +343,6 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel ...@@ -354,7 +343,6 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
break; break;
case HID_UP_CONSUMER: /* USB HUT v1.1, pages 56-62 */ case HID_UP_CONSUMER: /* USB HUT v1.1, pages 56-62 */
switch (usage->hid & HID_USAGE) { switch (usage->hid & HID_USAGE) {
case 0x000: goto ignore; case 0x000: goto ignore;
case 0x034: map_key_clear(KEY_SLEEP); break; case 0x034: map_key_clear(KEY_SLEEP); break;
...@@ -469,7 +457,6 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel ...@@ -469,7 +457,6 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
break; break;
case HID_UP_HPVENDOR: /* Reported on a Dutch layout HP5308 */ case HID_UP_HPVENDOR: /* Reported on a Dutch layout HP5308 */
set_bit(EV_REP, input->evbit); set_bit(EV_REP, input->evbit);
switch (usage->hid & HID_USAGE) { switch (usage->hid & HID_USAGE) {
case 0x021: map_key_clear(KEY_PRINT); break; case 0x021: map_key_clear(KEY_PRINT); break;
...@@ -489,21 +476,17 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel ...@@ -489,21 +476,17 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
break; break;
case HID_UP_MSVENDOR: case HID_UP_MSVENDOR:
goto ignore; goto ignore;
case HID_UP_CUSTOM: /* Reported on Logitech and Apple USB keyboards */ case HID_UP_CUSTOM: /* Reported on Logitech and Apple USB keyboards */
set_bit(EV_REP, input->evbit); set_bit(EV_REP, input->evbit);
goto ignore; goto ignore;
case HID_UP_LOGIVENDOR: case HID_UP_LOGIVENDOR:
goto ignore; goto ignore;
case HID_UP_PID: case HID_UP_PID:
switch (usage->hid & HID_USAGE) {
switch(usage->hid & HID_USAGE) {
case 0xa4: map_key_clear(BTN_DEAD); break; case 0xa4: map_key_clear(BTN_DEAD); break;
default: goto ignore; default: goto ignore;
} }
......
...@@ -369,7 +369,8 @@ static void hid_ctrl(struct urb *urb) ...@@ -369,7 +369,8 @@ static void hid_ctrl(struct urb *urb)
switch (urb->status) { switch (urb->status) {
case 0: /* success */ case 0: /* success */
if (usbhid->ctrl[usbhid->ctrltail].dir == USB_DIR_IN) if (usbhid->ctrl[usbhid->ctrltail].dir == USB_DIR_IN)
hid_input_report(urb->context, usbhid->ctrl[usbhid->ctrltail].report->type, hid_input_report(urb->context,
usbhid->ctrl[usbhid->ctrltail].report->type,
urb->transfer_buffer, urb->actual_length, 0); urb->transfer_buffer, urb->actual_length, 0);
break; break;
case -ESHUTDOWN: /* unplug */ case -ESHUTDOWN: /* unplug */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment