drivers: hid: lightly fix code style
PATCH 1/4 drivers: hid: lightly fix code style
Signed-off-by Simao Gomes Viana <[email protected]>
--- drivers/hid/hid-input.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/hid/hid-input.c +10 -4
@@ -1185,7 +1185,8 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fielif (field->application ==HID_GD_GAMEPAD || field->application ==HID_GD_JOYSTICK )input_set_abs_params (input, usage->code, a, b, (b - a) >>8 , (b - a) >>4 ); -else input_set_abs_params (input, usage->code, a, b,0 ,0 ); +else +input_set_abs_params (input, usage->code, a, b,0 ,0 );input_abs_set_res (input, usage->code,hidinput_calc_abs_res (field, usage->code));
@@ -1198,6 +1199,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fielif (usage->type ==EV_ABS && (usage->hat_min < usage->hat_max || usage->hat_dir)) {int i; +for (i = usage->code; i < usage->code +2 && i <= max; i++) {input_set_abs_params (input, i,-1 ,1 ,0 ,0 );set_bit (i, input->absbit);
@@ -1280,10 +1282,12 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, structif (usage->hat_min < usage->hat_max || usage->hat_dir) {int hat_dir = usage->hat_dir; +if (!hat_dir) hat_dir = (value - usage->hat_min) *8 / (usage->hat_max - usage->hat_min +1 ) +1 ; -if (hat_dir <0 || hat_dir >8 ) hat_dir =0 ; -input_event (input, usage->type, usage->code , hid_hat_to_axis[hat_dir].x); +if (hat_dir <0 || hat_dir >8 ) + hat_dir =0 ; +input_event (input, usage->type, usage->code, hid_hat_to_axis[hat_dir].x);input_event (input, usage->type, usage->code +1 , hid_hat_to_axis[hat_dir].y);return ; }
@@ -1306,11 +1310,12 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, structif (usage->hid == (HID_UP_DIGITIZER |0x0030 ) && (*quirks &HID_QUIRK_NOTOUCH )) {/* Pressure */ int a = field->logical_minimum;int b = field->logical_maximum; +input_event (input,EV_KEY ,BTN_TOUCH , value > a + ((b - a) >>3 )); }if (usage->hid == (HID_UP_PID |0x83UL )) {/* Simultaneous Effects Max */ -dbg_hid ("Maximum Effects - %d\n" ,value); +dbg_hid ("Maximum Effects - %d\n" , value);return ; }
@@ -1869,6 +1874,7 @@ int hidinput_connect(struct hid_device *hid, unsigned int force)if (!force) {for (i =0 ; i < hid->maxcollection; i++) {struct hid_collection *col = &hid->collection[i]; +if (col->type ==HID_COLLECTION_APPLICATION || col->type ==HID_COLLECTION_PHYSICAL )if (IS_INPUT_APPLICATION (col->usage))
Signature · 1 line
2.27.0
PATCH 2/4 drivers: hid: code style fixes
Signed-off-by Simao Gomes Viana <[email protected]>
--- drivers/hid/hid-input.c | 99 ++++++++++++++++++++++++++++------------- 1 file changed, 67 insertions(+), 32 deletions(-)
drivers/hid/hid-input.c +67 -32
@@ -751,17 +751,17 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fielcase HID_UP_LED :switch (usage->hid &0xffff ) {/* HID-Value: */ -case 0x01 :map_led (LED_NUML );break ;/* "Num Lock" */ -case 0x02 :map_led (LED_CAPSL );break ;/* "Caps Lock" */ -case 0x03 :map_led (LED_SCROLLL );break ;/* "Scroll Lock" */ -case 0x04 :map_led (LED_COMPOSE );break ;/* "Compose" */ -case 0x05 :map_led (LED_KANA );break ;/* "Kana" */ -case 0x27 :map_led (LED_SLEEP );break ;/* "Stand-By" */ -case 0x4c :map_led (LED_SUSPEND );break ;/* "System Suspend" */ -case 0x09 :map_led (LED_MUTE );break ;/* "Mute" */ -case 0x4b :map_led (LED_MISC );break ;/* "Generic Indicator" */ -case 0x19 :map_led (LED_MAIL );break ;/* "Message Waiting" */ -case 0x4d :map_led (LED_CHARGING );break ;/* "External Power Connected" */ +case 0x01 :map_led (LED_NUML );break ;/* "Num Lock" */ +case 0x02 :map_led (LED_CAPSL );break ;/* "Caps Lock" */ +case 0x03 :map_led (LED_SCROLLL );break ;/* "Scroll Lock" */ +case 0x04 :map_led (LED_COMPOSE );break ;/* "Compose" */ +case 0x05 :map_led (LED_KANA );break ;/* "Kana" */ +case 0x27 :map_led (LED_SLEEP );break ;/* "Stand-By" */ +case 0x4c :map_led (LED_SUSPEND );break ;/* "System Suspend" */ +case 0x09 :map_led (LED_MUTE );break ;/* "Mute" */ +case 0x4b :map_led (LED_MISC );break ;/* "Generic Indicator" */ +case 0x19 :map_led (LED_MAIL );break ;/* "Message Waiting" */ +case 0x4d :map_led (LED_CHARGING );break ;/* "External Power Connected" */ default : goto ignore; }
@@ -1066,29 +1066,61 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fielcase HID_UP_HPVENDOR :/* Reported on a Dutch layout HP5308 */ set_bit (EV_REP , input->evbit);switch (usage->hid &HID_USAGE ) { -case 0x021 :map_key_clear (KEY_PRINT );break ; -case 0x070 :map_key_clear (KEY_HP );break ; -case 0x071 :map_key_clear (KEY_CAMERA );break ; -case 0x072 :map_key_clear (KEY_SOUND );break ; -case 0x073 :map_key_clear (KEY_QUESTION );break ; -case 0x080 :map_key_clear (KEY_EMAIL );break ; -case 0x081 :map_key_clear (KEY_CHAT );break ; -case 0x082 :map_key_clear (KEY_SEARCH );break ; -case 0x083 :map_key_clear (KEY_CONNECT );break ; -case 0x084 :map_key_clear (KEY_FINANCE );break ; -case 0x085 :map_key_clear (KEY_SPORT );break ; -case 0x086 :map_key_clear (KEY_SHOP );break ; -default : goto ignore; +case 0x021 : +map_key_clear (KEY_PRINT ); +break ; +case 0x070 : +map_key_clear (KEY_HP ); +break ; +case 0x071 : +map_key_clear (KEY_CAMERA ); +break ; +case 0x072 : +map_key_clear (KEY_SOUND ); +break ; +case 0x073 : +map_key_clear (KEY_QUESTION ); +break ; +case 0x080 : +map_key_clear (KEY_EMAIL ); +break ; +case 0x081 : +map_key_clear (KEY_CHAT ); +break ; +case 0x082 : +map_key_clear (KEY_SEARCH ); +break ; +case 0x083 : +map_key_clear (KEY_CONNECT ); +break ; +case 0x084 : +map_key_clear (KEY_FINANCE ); +break ; +case 0x085 : +map_key_clear (KEY_SPORT ); +break ; +case 0x086 : +map_key_clear (KEY_SHOP ); +break ; +default : + goto ignore; }break ;case HID_UP_HPVENDOR2 :set_bit (EV_REP , input->evbit);switch (usage->hid &HID_USAGE ) { -case 0x001 :map_key_clear (KEY_MICMUTE );break ; -case 0x003 :map_key_clear (KEY_BRIGHTNESSDOWN );break ; -case 0x004 :map_key_clear (KEY_BRIGHTNESSUP );break ; -default : goto ignore; +case 0x001 : +map_key_clear (KEY_MICMUTE ); +break ; +case 0x003 : +map_key_clear (KEY_BRIGHTNESSDOWN ); +break ; +case 0x004 : +map_key_clear (KEY_BRIGHTNESSUP ); +break ; +default : + goto ignore; }break ;
@@ -1108,13 +1140,16 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fielcase HID_UP_PID :switch (usage->hid &HID_USAGE ) { -case 0xa4 :map_key_clear (BTN_DEAD );break ; -default : goto ignore; +case 0xa4 : +map_key_clear (BTN_DEAD ); +break ; +default : + goto ignore; }break ;default : - unknown: +unknown:if (field->report_size ==1 ) {if (field->report->type ==HID_OUTPUT_REPORT ) {map_led (LED_MISC );
@@ -1383,7 +1418,7 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct* skip the keycode translation and only forward real events. */ if (!(field->flags & (HID_MAIN_ITEM_RELATIVE | -HID_MAIN_ITEM_BUFFERED_BYTE )) && +HID_MAIN_ITEM_BUFFERED_BYTE )) && (field->flags &HID_MAIN_ITEM_VARIABLE ) && usage->usage_index < field->maxusage && value == field->value[usage->usage_index])
Signature · 1 line
2.27.0
PATCH 3/4 drivers: hid: change unsigned to unsigned int
In reply to Simao Gomes Vianaas per scripts/checkpatch.pl
--- drivers/hid/hid-input.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/hid/hid-input.c +6 -6
@@ -322,9 +322,9 @@ static const struct hid_device_id hid_battery_quirks[] = { {} }; -static unsigned find_battery_quirk (struct hid_device *hdev) +static unsigned int find_battery_quirk (struct hid_device *hdev) { -unsigned quirks =0 ; +unsigned int quirks =0 ;const struct hid_device_id *match; match =hid_match_id (hdev, hid_battery_quirks);
@@ -428,11 +428,11 @@ static int hidinput_get_battery_property(struct power_supply *psy,return ret; } -static int hidinput_setup_battery (struct hid_device *dev,unsigned report_type,struct hid_field *field) +static int hidinput_setup_battery (struct hid_device *dev,unsigned int report_type,struct hid_field *field) {struct power_supply_desc *psy_desc;struct power_supply_config psy_cfg = { .drv_data = dev, }; -unsigned quirks; +unsigned int quirks;s32 min, max;int error;
@@ -541,7 +541,7 @@ static void hidinput_update_battery(struct hid_device *dev, int value) } }#else /* !CONFIG_HID_BATTERY_STRENGTH */ -static int hidinput_setup_battery (struct hid_device *dev,unsigned report_type, +static int hidinput_setup_battery (struct hid_device *dev,unsigned int report_type,struct hid_field *field) {return 0 ;
@@ -1300,7 +1300,7 @@ static void hidinput_handle_scroll(struct hid_usage *usage,void hidinput_hid_event (struct hid_device *hid,struct hid_field *field,struct hid_usage *usage,__s32 value) {struct input_dev *input; -unsigned *quirks = &hid->quirks; +unsigned int *quirks = &hid->quirks;if (!usage->type)return ;
Signature · 1 line
2.27.0
PATCH 4/4 drivers: hid: move trailing block comment close to new line
In reply to Simao Gomes VianaSigned-off-by Simao Gomes Viana <[email protected]>
--- drivers/hid/hid-input.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/hid/hid-input.c +2 -1
@@ -2016,7 +2016,8 @@ void hidinput_disconnect(struct hid_device *hid)/* led_work is spawned by input_dev callbacks, but doesn't access the * parent input_dev at all. Once all input devices are removed, we * know that led_work will never get restarted, so we can cancel it -* synchronously and are safe. */ +* synchronously and are safe. +*/ cancel_work_sync (&hid->led_work); }EXPORT_SYMBOL_GPL (hidinput_disconnect);
Signature · 1 line
2.27.0