diff mbox series

staging: drivers: hid: hid-asus.c: Fixed brace/formatting issues.

Message ID 20220508125056.354001-1-jb@ip.fi (mailing list archive)
State New
Delegated to: Jiri Kosina
Headers show
Series staging: drivers: hid: hid-asus.c: Fixed brace/formatting issues. | expand

Commit Message

Johan Boger May 8, 2022, 12:50 p.m. UTC
Fixed formatting issues based on recommendations from 
scripts/checkpatch.pl, in accordance with coding style.

Signed-off-by: Johan Boger <jb@ip.fi>
---
 drivers/hid/hid-asus.c | 172 +++++++++++++++++++++++++++++------------
 1 file changed, 121 insertions(+), 51 deletions(-)

Comments

Joe Perches May 8, 2022, 4:47 p.m. UTC | #1
On Sun, 2022-05-08 at 14:50 +0200, Johan Boger wrote:
> Fixed formatting issues based on recommendations from 
> scripts/checkpatch.pl, in accordance with coding style.
[]
> diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
[]
> @@ -852,47 +850,86 @@ static int asus_input_mapping(struct hid_device *hdev,
>  	/* ASUS-specific keyboard hotkeys and led backlight */
>  	if ((usage->hid & HID_USAGE_PAGE) == HID_UP_ASUSVENDOR) {
>  		switch (usage->hid & HID_USAGE) {
> -		case 0x10: asus_map_key_clear(KEY_BRIGHTNESSDOWN);	break;
[...]

I think the break on the same line isn't that difficult a style.

All of these changes would be better with different code setting
a temporary then a single call to asus_map_key_clear(temp);

It'd also make the object code rather smaller.

$ size drivers/hid/hid-asus.o* (x86-64 defconfig with hid-asus)
   text	   data	    bss	    dec	    hex	filename
  10695	    420	      0	  11115	   2b6b	drivers/hid/hid-asus.o.new
  14108	    420	      0	  14528	   38c0	drivers/hid/hid-asus.o.old
---
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 08c9a9a60ae47..4702902ee4dad 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -827,6 +827,7 @@ static int asus_input_mapping(struct hid_device *hdev,
 		struct hid_usage *usage, unsigned long **bit,
 		int *max)
 {
+	int clear_key;
 	struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
 
 	if (drvdata->quirks & QUIRK_SKIP_INPUT_MAPPING) {
@@ -852,43 +853,43 @@ static int asus_input_mapping(struct hid_device *hdev,
 	/* ASUS-specific keyboard hotkeys and led backlight */
 	if ((usage->hid & HID_USAGE_PAGE) == HID_UP_ASUSVENDOR) {
 		switch (usage->hid & HID_USAGE) {
-		case 0x10: asus_map_key_clear(KEY_BRIGHTNESSDOWN);	break;
-		case 0x20: asus_map_key_clear(KEY_BRIGHTNESSUP);		break;
-		case 0x35: asus_map_key_clear(KEY_DISPLAY_OFF);		break;
-		case 0x6c: asus_map_key_clear(KEY_SLEEP);		break;
-		case 0x7c: asus_map_key_clear(KEY_MICMUTE);		break;
-		case 0x82: asus_map_key_clear(KEY_CAMERA);		break;
-		case 0x88: asus_map_key_clear(KEY_RFKILL);			break;
-		case 0xb5: asus_map_key_clear(KEY_CALC);			break;
-		case 0xc4: asus_map_key_clear(KEY_KBDILLUMUP);		break;
-		case 0xc5: asus_map_key_clear(KEY_KBDILLUMDOWN);		break;
+		case 0x10: clear_key = KEY_BRIGHTNESSDOWN;	break;
+		case 0x20: clear_key = KEY_BRIGHTNESSUP;	break;
+		case 0x35: clear_key = KEY_DISPLAY_OFF;		break;
+		case 0x6c: clear_key = KEY_SLEEP;		break;
+		case 0x7c: clear_key = KEY_MICMUTE;		break;
+		case 0x82: clear_key = KEY_CAMERA;		break;
+		case 0x88: clear_key = KEY_RFKILL;		break;
+		case 0xb5: clear_key = KEY_CALC;		break;
+		case 0xc4: clear_key = KEY_KBDILLUMUP;		break;
+		case 0xc5: clear_key = KEY_KBDILLUMDOWN;	break;
 
 		/* ASUS touchpad toggle */
-		case 0x6b: asus_map_key_clear(KEY_F21);			break;
+		case 0x6b: clear_key = KEY_F21;			break;
 
 		/* ROG key */
-		case 0x38: asus_map_key_clear(KEY_PROG1);		break;
+		case 0x38: clear_key = KEY_PROG1;		break;
 
 		/* Fn+C ASUS Splendid */
-		case 0xba: asus_map_key_clear(KEY_PROG2);		break;
+		case 0xba: clear_key = KEY_PROG2;		break;
 
 		/* Fn+Space Power4Gear Hybrid */
-		case 0x5c: asus_map_key_clear(KEY_PROG3);		break;
+		case 0x5c: clear_key = KEY_PROG3;		break;
 
 		/* Fn+F5 "fan" symbol on FX503VD */
-		case 0x99: asus_map_key_clear(KEY_PROG4);		break;
+		case 0x99: clear_key = KEY_PROG4;		break;
 
 		/* Fn+F5 "fan" symbol on N-Key keyboard */
-		case 0xae: asus_map_key_clear(KEY_PROG4);		break;
+		case 0xae: clear_key = KEY_PROG4;		break;
 
 		/* Fn+Ret "Calc" symbol on N-Key keyboard */
-		case 0x92: asus_map_key_clear(KEY_CALC);		break;
+		case 0x92: clear_key = KEY_CALC;		break;
 
 		/* Fn+Left Aura mode previous on N-Key keyboard */
-		case 0xb2: asus_map_key_clear(KEY_PROG2);		break;
+		case 0xb2: clear_key = KEY_PROG2;		break;
 
 		/* Fn+Right Aura mode next on N-Key keyboard */
-		case 0xb3: asus_map_key_clear(KEY_PROG3);		break;
+		case 0xb3: clear_key = KEY_PROG3;		break;
 
 		default:
 			/* ASUS lazily declares 256 usages, ignore the rest,
@@ -896,6 +897,8 @@ static int asus_input_mapping(struct hid_device *hdev,
 			return -1;
 		}
 
+		asus_map_key_clear(clear_key);
+
 		/*
 		 * Check and enable backlight only on devices with UsagePage ==
 		 * 0xff31 to avoid initializing the keyboard firmware multiple
@@ -911,27 +914,29 @@ static int asus_input_mapping(struct hid_device *hdev,
 
 	if ((usage->hid & HID_USAGE_PAGE) == HID_UP_MSVENDOR) {
 		switch (usage->hid & HID_USAGE) {
-		case 0xff01: asus_map_key_clear(BTN_1);	break;
-		case 0xff02: asus_map_key_clear(BTN_2);	break;
-		case 0xff03: asus_map_key_clear(BTN_3);	break;
-		case 0xff04: asus_map_key_clear(BTN_4);	break;
-		case 0xff05: asus_map_key_clear(BTN_5);	break;
-		case 0xff06: asus_map_key_clear(BTN_6);	break;
-		case 0xff07: asus_map_key_clear(BTN_7);	break;
-		case 0xff08: asus_map_key_clear(BTN_8);	break;
-		case 0xff09: asus_map_key_clear(BTN_9);	break;
-		case 0xff0a: asus_map_key_clear(BTN_A);	break;
-		case 0xff0b: asus_map_key_clear(BTN_B);	break;
-		case 0x00f1: asus_map_key_clear(KEY_WLAN);	break;
-		case 0x00f2: asus_map_key_clear(KEY_BRIGHTNESSDOWN);	break;
-		case 0x00f3: asus_map_key_clear(KEY_BRIGHTNESSUP);	break;
-		case 0x00f4: asus_map_key_clear(KEY_DISPLAY_OFF);	break;
-		case 0x00f7: asus_map_key_clear(KEY_CAMERA);	break;
-		case 0x00f8: asus_map_key_clear(KEY_PROG1);	break;
+		case 0xff01: clear_key = BTN_1;			break;
+		case 0xff02: clear_key = BTN_2;			break;
+		case 0xff03: clear_key = BTN_3;			break;
+		case 0xff04: clear_key = BTN_4;			break;
+		case 0xff05: clear_key = BTN_5;			break;
+		case 0xff06: clear_key = BTN_6;			break;
+		case 0xff07: clear_key = BTN_7;			break;
+		case 0xff08: clear_key = BTN_8;			break;
+		case 0xff09: clear_key = BTN_9;			break;
+		case 0xff0a: clear_key = BTN_A;			break;
+		case 0xff0b: clear_key = BTN_B;			break;
+		case 0x00f1: clear_key = KEY_WLAN;		break;
+		case 0x00f2: clear_key = KEY_BRIGHTNESSDOWN;	break;
+		case 0x00f3: clear_key = KEY_BRIGHTNESSUP;	break;
+		case 0x00f4: clear_key = KEY_DISPLAY_OFF;	break;
+		case 0x00f7: clear_key = KEY_CAMERA;		break;
+		case 0x00f8: clear_key = KEY_PROG1;		break;
 		default:
 			return 0;
 		}
 
+		asus_map_key_clear(clear_key);
+
 		set_bit(EV_REP, hi->input->evbit);
 		return 1;
 	}
diff mbox series

Patch

diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 08c9a9a60ae4..c76ca7416bac 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -339,7 +339,7 @@  static int asus_raw_event(struct hid_device *hdev,
 		/*
 		 * Skip these report ID, the device emits a continuous stream associated
 		 * with the AURA mode it is in which looks like an 'echo'.
-		*/
+		 */
 		if (report->id == FEATURE_KBD_LED_REPORT_ID1 ||
 				report->id == FEATURE_KBD_LED_REPORT_ID2) {
 			return -1;
@@ -349,7 +349,7 @@  static int asus_raw_event(struct hid_device *hdev,
 			 * G14 and G15 send these codes on some keypresses with no
 			 * discernable reason for doing so. We'll filter them out to avoid
 			 * unmapped warning messages later.
-			*/
+			 */
 			if (data[1] == 0xea || data[1] == 0xec || data[1] == 0x02 ||
 					data[1] == 0x8a || data[1] == 0x9e) {
 				return -1;
@@ -359,10 +359,9 @@  static int asus_raw_event(struct hid_device *hdev,
 			/*
 			 * G713 and G733 send these codes on some keypresses, depending on
 			 * the key pressed it can trigger a shutdown event if not caught.
-			*/
-			if(data[0] == 0x02 && data[1] == 0x30) {
+			 */
+			if (data[0] == 0x02 && data[1] == 0x30)
 				return -1;
-			}
 		}
 
 	}
@@ -371,11 +370,10 @@  static int asus_raw_event(struct hid_device *hdev,
 		/*
 		 * CLAYMORE II keyboard sends this packet when it goes to sleep
 		 * this causes the whole system to go into suspend.
-		*/
+		 */
 
-		if(size == 2 && data[0] == 0x02 && data[1] == 0x00) {
+		if (size == 2 && data[0] == 0x02 && data[1] == 0x00)
 			return -1;
-		}
 	}
 
 	return 0;
@@ -393,7 +391,7 @@  static int asus_kbd_set_report(struct hid_device *hdev, u8 *buf, size_t buf_size
 	/*
 	 * The report ID should be set from the incoming buffer due to LED and key
 	 * interfaces having different pages
-	*/
+	 */
 	ret = hid_hw_raw_request(hdev, buf[0], dmabuf,
 				 buf_size, HID_FEATURE_REPORT,
 				 HID_REQ_SET_REPORT);
@@ -852,47 +850,86 @@  static int asus_input_mapping(struct hid_device *hdev,
 	/* ASUS-specific keyboard hotkeys and led backlight */
 	if ((usage->hid & HID_USAGE_PAGE) == HID_UP_ASUSVENDOR) {
 		switch (usage->hid & HID_USAGE) {
-		case 0x10: asus_map_key_clear(KEY_BRIGHTNESSDOWN);	break;
-		case 0x20: asus_map_key_clear(KEY_BRIGHTNESSUP);		break;
-		case 0x35: asus_map_key_clear(KEY_DISPLAY_OFF);		break;
-		case 0x6c: asus_map_key_clear(KEY_SLEEP);		break;
-		case 0x7c: asus_map_key_clear(KEY_MICMUTE);		break;
-		case 0x82: asus_map_key_clear(KEY_CAMERA);		break;
-		case 0x88: asus_map_key_clear(KEY_RFKILL);			break;
-		case 0xb5: asus_map_key_clear(KEY_CALC);			break;
-		case 0xc4: asus_map_key_clear(KEY_KBDILLUMUP);		break;
-		case 0xc5: asus_map_key_clear(KEY_KBDILLUMDOWN);		break;
+		case 0x10:
+			asus_map_key_clear(KEY_BRIGHTNESSDOWN);
+			break;
+		case 0x20:
+			asus_map_key_clear(KEY_BRIGHTNESSUP);
+			break;
+		case 0x35:
+			asus_map_key_clear(KEY_DISPLAY_OFF);
+			break;
+		case 0x6c:
+			asus_map_key_clear(KEY_SLEEP);
+			break;
+		case 0x7c:
+			asus_map_key_clear(KEY_MICMUTE);
+			break;
+		case 0x82:
+			asus_map_key_clear(KEY_CAMERA);
+			break;
+		case 0x88:
+			asus_map_key_clear(KEY_RFKILL);
+			break;
+		case 0xb5:
+			asus_map_key_clear(KEY_CALC);
+			break;
+		case 0xc4:
+			asus_map_key_clear(KEY_KBDILLUMUP);
+			break;
+		case 0xc5:
+			asus_map_key_clear(KEY_KBDILLUMDOWN);
+			break;
 
 		/* ASUS touchpad toggle */
-		case 0x6b: asus_map_key_clear(KEY_F21);			break;
+		case 0x6b:
+			asus_map_key_clear(KEY_F21);
+			break;
 
 		/* ROG key */
-		case 0x38: asus_map_key_clear(KEY_PROG1);		break;
+		case 0x38:
+			asus_map_key_clear(KEY_PROG1);
+			break;
 
 		/* Fn+C ASUS Splendid */
-		case 0xba: asus_map_key_clear(KEY_PROG2);		break;
+		case 0xba:
+			asus_map_key_clear(KEY_PROG2);
+			break;
 
 		/* Fn+Space Power4Gear Hybrid */
-		case 0x5c: asus_map_key_clear(KEY_PROG3);		break;
+		case 0x5c:
+			asus_map_key_clear(KEY_PROG3);
+			break;
 
 		/* Fn+F5 "fan" symbol on FX503VD */
-		case 0x99: asus_map_key_clear(KEY_PROG4);		break;
+		case 0x99:
+			asus_map_key_clear(KEY_PROG4);
+			break;
 
 		/* Fn+F5 "fan" symbol on N-Key keyboard */
-		case 0xae: asus_map_key_clear(KEY_PROG4);		break;
+		case 0xae:
+			asus_map_key_clear(KEY_PROG4);
+			break;
 
 		/* Fn+Ret "Calc" symbol on N-Key keyboard */
-		case 0x92: asus_map_key_clear(KEY_CALC);		break;
+		case 0x92:
+			asus_map_key_clear(KEY_CALC);
+			break;
 
 		/* Fn+Left Aura mode previous on N-Key keyboard */
-		case 0xb2: asus_map_key_clear(KEY_PROG2);		break;
+		case 0xb2:
+			asus_map_key_clear(KEY_PROG2);
+			break;
 
 		/* Fn+Right Aura mode next on N-Key keyboard */
-		case 0xb3: asus_map_key_clear(KEY_PROG3);		break;
+		case 0xb3:
+			asus_map_key_clear(KEY_PROG3);
+			break;
 
 		default:
 			/* ASUS lazily declares 256 usages, ignore the rest,
-			 * as some make the keyboard appear as a pointer device. */
+			 * as some make the keyboard appear as a pointer device.
+			 */
 			return -1;
 		}
 
@@ -911,23 +948,57 @@  static int asus_input_mapping(struct hid_device *hdev,
 
 	if ((usage->hid & HID_USAGE_PAGE) == HID_UP_MSVENDOR) {
 		switch (usage->hid & HID_USAGE) {
-		case 0xff01: asus_map_key_clear(BTN_1);	break;
-		case 0xff02: asus_map_key_clear(BTN_2);	break;
-		case 0xff03: asus_map_key_clear(BTN_3);	break;
-		case 0xff04: asus_map_key_clear(BTN_4);	break;
-		case 0xff05: asus_map_key_clear(BTN_5);	break;
-		case 0xff06: asus_map_key_clear(BTN_6);	break;
-		case 0xff07: asus_map_key_clear(BTN_7);	break;
-		case 0xff08: asus_map_key_clear(BTN_8);	break;
-		case 0xff09: asus_map_key_clear(BTN_9);	break;
-		case 0xff0a: asus_map_key_clear(BTN_A);	break;
-		case 0xff0b: asus_map_key_clear(BTN_B);	break;
-		case 0x00f1: asus_map_key_clear(KEY_WLAN);	break;
-		case 0x00f2: asus_map_key_clear(KEY_BRIGHTNESSDOWN);	break;
-		case 0x00f3: asus_map_key_clear(KEY_BRIGHTNESSUP);	break;
-		case 0x00f4: asus_map_key_clear(KEY_DISPLAY_OFF);	break;
-		case 0x00f7: asus_map_key_clear(KEY_CAMERA);	break;
-		case 0x00f8: asus_map_key_clear(KEY_PROG1);	break;
+		case 0xff01:
+			asus_map_key_clear(BTN_1);
+			break;
+		case 0xff02:
+			asus_map_key_clear(BTN_2);
+			break;
+		case 0xff03:
+			asus_map_key_clear(BTN_3);
+			break;
+		case 0xff04:
+			asus_map_key_clear(BTN_4);
+			break;
+		case 0xff05:
+			asus_map_key_clear(BTN_5);
+			break;
+		case 0xff06:
+			asus_map_key_clear(BTN_6);
+			break;
+		case 0xff07:
+			asus_map_key_clear(BTN_7);
+			break;
+		case 0xff08:
+			asus_map_key_clear(BTN_8);
+			break;
+		case 0xff09:
+			asus_map_key_clear(BTN_9);
+			break;
+		case 0xff0a:
+			asus_map_key_clear(BTN_A);
+			break;
+		case 0xff0b:
+			asus_map_key_clear(BTN_B);
+			break;
+		case 0x00f1:
+			asus_map_key_clear(KEY_WLAN);
+			break;
+		case 0x00f2:
+			asus_map_key_clear(KEY_BRIGHTNESSDOWN);
+			break;
+		case 0x00f3:
+			asus_map_key_clear(KEY_BRIGHTNESSUP);
+			break;
+		case 0x00f4:
+			asus_map_key_clear(KEY_DISPLAY_OFF);
+			break;
+		case 0x00f7:
+			asus_map_key_clear(KEY_CAMERA);
+			break;
+		case 0x00f8:
+			asus_map_key_clear(KEY_PROG1);
+			break;
 		default:
 			return 0;
 		}
@@ -1100,11 +1171,10 @@  static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
 		goto err_stop_hw;
 	}
 
-	if (drvdata->tp) {
+	if (drvdata->tp)
 		drvdata->input->name = "Asus TouchPad";
-	} else {
+	else
 		drvdata->input->name = "Asus Keyboard";
-	}
 
 	if (drvdata->tp) {
 		ret = asus_start_multitouch(hdev);
@@ -1131,8 +1201,8 @@  static void asus_remove(struct hid_device *hdev)
 }
 
 static const __u8 asus_g752_fixed_rdesc[] = {
-        0x19, 0x00,			/*   Usage Minimum (0x00)       */
-        0x2A, 0xFF, 0x00,		/*   Usage Maximum (0xFF)       */
+	0x19, 0x00,			/*   Usage Minimum (0x00)       */
+	0x2A, 0xFF, 0x00,		/*   Usage Maximum (0xFF)       */
 };
 
 static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,