Skip to contentSkip to conversation

platform/x86: intel-vbtn: Fix code style issues

PATCH In review Xiang Shen 3 participants 7 messages Jun 20, 2025 – Jun 26, 2025

Subsystems (2)
lore
Share & tools
lore

Xiang Shen

author
#0 lore raw

PATCH 1/1 platform/x86: intel-vbtn: Fix code style issues

Fix checkpatch code style errors:

ERROR: do not use assignment in if condition
+ if ((ke = sparse_keymap_entry_from_scancode(priv->buttons_dev, event))) {

ERROR: do not use assignment in if condition
+ } else if ((ke = sparse_keymap_entry_from_scancode(priv->switches_dev, event))) {

---
 drivers/platform/x86/intel/vbtn.c | 38 +++++++++++++++++--------------
 1 file changed, 21 insertions(+), 17 deletions(-)
drivers/platform/x86/intel/vbtn.c +21 -17
index 232cd12e3c9f..bcc97b06844e 100644
@@ -160,30 +160,34 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
 
 	guard(mutex)(&priv->mutex);
 
-	if ((ke = sparse_keymap_entry_from_scancode(priv->buttons_dev, event))) {
+	ke = sparse_keymap_entry_from_scancode(priv->buttons_dev, event);
+	if (ke) {
 		if (!priv->has_buttons) {
 			dev_warn(&device->dev, "Warning: received 0x%02x button event on a device without buttons, please report this.\n",
 				 event);
 			return;
 		}
 		input_dev = priv->buttons_dev;
-	} else if ((ke = sparse_keymap_entry_from_scancode(priv->switches_dev, event))) {
-		if (!priv->has_switches) {
-			/* See dual_accel_detect.h for more info */
-			if (priv->dual_accel)
-				return;
-
-			dev_info(&device->dev, "Registering Intel Virtual Switches input-dev after receiving a switch event\n");
-			ret = input_register_device(priv->switches_dev);
-			if (ret)
-				return;
-
-			priv->has_switches = true;
-		}
-		input_dev = priv->switches_dev;
 	} else {
-		dev_dbg(&device->dev, "unknown event index 0x%x\n", event);
-		return;
+		ke = sparse_keymap_entry_from_scancode(priv->switches_dev, event);
+		if (ke) {
+			if (!priv->has_switches) {
+				/* See dual_accel_detect.h for more info */
+				if (priv->dual_accel)
+					return;
+
+				dev_info(&device->dev, "Registering Intel Virtual Switches input-dev after receiving a switch event\n");
+				ret = input_register_device(priv->switches_dev);
+				if (ret)
+					return;
+
+				priv->has_switches = true;
+			}
+			input_dev = priv->switches_dev;
+		} else {
+			dev_dbg(&device->dev, "unknown event index 0x%x\n", event);
+			return;
+		}
 	}
 
 	if (priv->wakeup_mode) {
Signature · 1 line
2.46.0
maintainer
#1 lore raw

Hi,

Quoted 9 lines · Xiang Shen

Fix checkpatch code style errors:

ERROR: do not use assignment in if condition

(quoted diff) +1 -0
+	if ((ke = sparse_keymap_entry_from_scancode(priv->buttons_dev, event))) {

ERROR: do not use assignment in if condition

(quoted diff) +1 -0
+	} else if ((ke = sparse_keymap_entry_from_scancode(priv->switches_dev, event))) {

Thank you for your patch, but this change really does not make the code more readable.

The contrary the suggested changes are making the code harder to read, so NACK.

Note checkpatch is just a tool, sometimes there are good reasons to deviate from the style checks done by checkpatch.

Next time when submitting a patch to fix checkpatch issues please take a look at the resulting code after the patch and only submit the patch upstream if it actually is an improvement.

Regards,

Hans

Quoted 60 lines
---
 drivers/platform/x86/intel/vbtn.c | 38 +++++++++++++++++--------------
 1 file changed, 21 insertions(+), 17 deletions(-)
drivers/platform/x86/intel/vbtn.c +21 -17
index 232cd12e3c9f..bcc97b06844e 100644
@@ -160,30 +160,34 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
 
 	guard(mutex)(&priv->mutex);
 
-	if ((ke = sparse_keymap_entry_from_scancode(priv->buttons_dev, event))) {
+	ke = sparse_keymap_entry_from_scancode(priv->buttons_dev, event);
+	if (ke) {
 		if (!priv->has_buttons) {
 			dev_warn(&device->dev, "Warning: received 0x%02x button event on a device without buttons, please report this.\n",
 				 event);
 			return;
 		}
 		input_dev = priv->buttons_dev;
-	} else if ((ke = sparse_keymap_entry_from_scancode(priv->switches_dev, event))) {
-		if (!priv->has_switches) {
-			/* See dual_accel_detect.h for more info */
-			if (priv->dual_accel)
-				return;
-
-			dev_info(&device->dev, "Registering Intel Virtual Switches input-dev after receiving a switch event\n");
-			ret = input_register_device(priv->switches_dev);
-			if (ret)
-				return;
-
-			priv->has_switches = true;
-		}
-		input_dev = priv->switches_dev;
 	} else {
-		dev_dbg(&device->dev, "unknown event index 0x%x\n", event);
-		return;
+		ke = sparse_keymap_entry_from_scancode(priv->switches_dev, event);
+		if (ke) {
+			if (!priv->has_switches) {
+				/* See dual_accel_detect.h for more info */
+				if (priv->dual_accel)
+					return;
+
+				dev_info(&device->dev, "Registering Intel Virtual Switches input-dev after receiving a switch event\n");
+				ret = input_register_device(priv->switches_dev);
+				if (ret)
+					return;
+
+				priv->has_switches = true;
+			}
+			input_dev = priv->switches_dev;
+		} else {
+			dev_dbg(&device->dev, "unknown event index 0x%x\n", event);
+			return;
+		}
 	}
 
 	if (priv->wakeup_mode) {
author
#2 lore raw
Quoted 22 lines · Hans de Goede

Hi,

Quoted 9 lines · Xiang Shen

Fix checkpatch code style errors:

ERROR: do not use assignment in if condition

(quoted diff) +1 -0
+	if ((ke = sparse_keymap_entry_from_scancode(priv->buttons_dev, event))) {

ERROR: do not use assignment in if condition

(quoted diff) +1 -0
+	} else if ((ke = sparse_keymap_entry_from_scancode(priv->switches_dev, event))) {

Thank you for your patch, but this change really does not make the code more readable.

The contrary the suggested changes are making the code harder to read, so NACK.

Note checkpatch is just a tool, sometimes there are good reasons to deviate from the style checks done by checkpatch.

Quoted 8 lines

Next time when submitting a patch to fix checkpatch issues please take a look at the resulting code after the patch and only submit the patch upstream if it actually is an improvement.

Regards,

Hans

Hi Hans,

Thanks for the feedback.

That's fine if breaking the "rule" is the only way to keep the file readable.

However, there are only three files (x86/sony-laptop.c and x86/dell/dell_rbu.c) out of 273 files in the whole drivers/platform folder that have such an error. Perhaps there are other approaches to make them more readable without breaking the rule.

BRs,
Xiang

Quoted 63 lines
Quoted 62 lines

---
 drivers/platform/x86/intel/vbtn.c | 38 +++++++++++++++++--------------
 1 file changed, 21 insertions(+), 17 deletions(-)
drivers/platform/x86/intel/vbtn.c +21 -17
index 232cd12e3c9f..bcc97b06844e 100644
@@ -160,30 +160,34 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
 
 	guard(mutex)(&priv->mutex);
 
-	if ((ke = sparse_keymap_entry_from_scancode(priv->buttons_dev, event))) {
+	ke = sparse_keymap_entry_from_scancode(priv->buttons_dev, event);
+	if (ke) {
 		if (!priv->has_buttons) {
 			dev_warn(&device->dev, "Warning: received 0x%02x button event on a device without buttons, please report this.\n",
 				 event);
 			return;
 		}
 		input_dev = priv->buttons_dev;
-	} else if ((ke = sparse_keymap_entry_from_scancode(priv->switches_dev, event))) {
-		if (!priv->has_switches) {
-			/* See dual_accel_detect.h for more info */
-			if (priv->dual_accel)
-				return;
-
-			dev_info(&device->dev, "Registering Intel Virtual Switches input-dev after receiving a switch event\n");
-			ret = input_register_device(priv->switches_dev);
-			if (ret)
-				return;
-
-			priv->has_switches = true;
-		}
-		input_dev = priv->switches_dev;
 	} else {
-		dev_dbg(&device->dev, "unknown event index 0x%x\n", event);
-		return;
+		ke = sparse_keymap_entry_from_scancode(priv->switches_dev, event);
+		if (ke) {
+			if (!priv->has_switches) {
+				/* See dual_accel_detect.h for more info */
+				if (priv->dual_accel)
+					return;
+
+				dev_info(&device->dev, "Registering Intel Virtual Switches input-dev after receiving a switch event\n");
+				ret = input_register_device(priv->switches_dev);
+				if (ret)
+					return;
+
+				priv->has_switches = true;
+			}
+			input_dev = priv->switches_dev;
+		} else {
+			dev_dbg(&device->dev, "unknown event index 0x%x\n", event);
+			return;
+		}
 	}
 
 	if (priv->wakeup_mode) {
maintainer
#3 lore raw
Quoted 31 lines · Xiang Shen
Quoted 20 lines · Hans de Goede
Quoted 9 lines · Xiang Shen

Fix checkpatch code style errors:

ERROR: do not use assignment in if condition

(quoted diff) +1 -0
+	if ((ke = sparse_keymap_entry_from_scancode(priv->buttons_dev, event))) {

ERROR: do not use assignment in if condition

(quoted diff) +1 -0
+	} else if ((ke = sparse_keymap_entry_from_scancode(priv->switches_dev, event))) {

Thank you for your patch, but this change really does not make the code more readable.

The contrary the suggested changes are making the code harder to read, so NACK.

Note checkpatch is just a tool, sometimes there are good reasons to deviate from the style checks done by checkpatch.

Quoted 8 lines

Next time when submitting a patch to fix checkpatch issues please take a look at the resulting code after the patch and only submit the patch upstream if it actually is an improvement.

Regards,

Hans

Hi Hans,

Quoted 7 lines

Thanks for the feedback.

That's fine if breaking the "rule" is the only way to keep the file readable.

However, there are only three files (x86/sony-laptop.c and x86/dell/dell_rbu.c) out of 273 files in the whole drivers/platform folder that have such an error.

Hi,

Please don't call correct code "error" even if checkpatch may label it as such. The goal is NOT and will never be to have zero checkpatch warnings.

The fact that the checkpatch "rule" is broken only a few times does not mean those 3 places have a problem, it just tells it's good rule for the general case. So I won't accept using such numbers as a leverage against the few places just for the sake of silencing checkpatch.

Quoted 2 lines

Perhaps there are other approaches to make them more readable without breaking the rule.

Perhaps, but I'm not sure the effort spent to find one is worthwhile investment.

Quoted 62 lines
Quoted 61 lines
Quoted 60 lines
---
 drivers/platform/x86/intel/vbtn.c | 38 +++++++++++++++++--------------
 1 file changed, 21 insertions(+), 17 deletions(-)
drivers/platform/x86/intel/vbtn.c +21 -17
index 232cd12e3c9f..bcc97b06844e 100644
@@ -160,30 +160,34 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
 
 	guard(mutex)(&priv->mutex);
 
-	if ((ke = sparse_keymap_entry_from_scancode(priv->buttons_dev, event))) {
+	ke = sparse_keymap_entry_from_scancode(priv->buttons_dev, event);
+	if (ke) {
 		if (!priv->has_buttons) {
 			dev_warn(&device->dev, "Warning: received 0x%02x button event on a device without buttons, please report this.\n",
 				 event);
 			return;
 		}
 		input_dev = priv->buttons_dev;
-	} else if ((ke = sparse_keymap_entry_from_scancode(priv->switches_dev, event))) {
-		if (!priv->has_switches) {
-			/* See dual_accel_detect.h for more info */
-			if (priv->dual_accel)
-				return;
-
-			dev_info(&device->dev, "Registering Intel Virtual Switches input-dev after receiving a switch event\n");
-			ret = input_register_device(priv->switches_dev);
-			if (ret)
-				return;
-
-			priv->has_switches = true;
-		}
-		input_dev = priv->switches_dev;
 	} else {
-		dev_dbg(&device->dev, "unknown event index 0x%x\n", event);
-		return;
+		ke = sparse_keymap_entry_from_scancode(priv->switches_dev, event);
+		if (ke) {
+			if (!priv->has_switches) {
+				/* See dual_accel_detect.h for more info */
+				if (priv->dual_accel)
+					return;
+
+				dev_info(&device->dev, "Registering Intel Virtual Switches input-dev after receiving a switch event\n");
+				ret = input_register_device(priv->switches_dev);
+				if (ret)
+					return;
+
+				priv->has_switches = true;
+			}
+			input_dev = priv->switches_dev;
+		} else {
+			dev_dbg(&device->dev, "unknown event index 0x%x\n", event);
+			return;
+		}
 	}
 
 	if (priv->wakeup_mode) {
Signature · 1 line
 i.
author
#4 lore raw
Quoted 42 lines · Ilpo Järvinen
Quoted 31 lines · Xiang Shen
Quoted 20 lines · Hans de Goede
Quoted 9 lines · Xiang Shen

Fix checkpatch code style errors:

ERROR: do not use assignment in if condition

(quoted diff) +1 -0
+	if ((ke = sparse_keymap_entry_from_scancode(priv->buttons_dev, event))) {

ERROR: do not use assignment in if condition

(quoted diff) +1 -0
+	} else if ((ke = sparse_keymap_entry_from_scancode(priv->switches_dev, event))) {

Thank you for your patch, but this change really does not make the code more readable.

The contrary the suggested changes are making the code harder to read, so NACK.

Note checkpatch is just a tool, sometimes there are good reasons to deviate from the style checks done by checkpatch.

Quoted 8 lines

Next time when submitting a patch to fix checkpatch issues please take a look at the resulting code after the patch and only submit the patch upstream if it actually is an improvement.

Regards,

Hans

Hi Hans,

Quoted 7 lines

Thanks for the feedback.

That's fine if breaking the "rule" is the only way to keep the file readable.

However, there are only three files (x86/sony-laptop.c and x86/dell/dell_rbu.c) out of 273 files in the whole drivers/platform folder that have such an error.

Hi,

Quoted 8 lines

Please don't call correct code "error" even if checkpatch may label it as such. The goal is NOT and will never be to have zero checkpatch warnings.

The fact that the checkpatch "rule" is broken only a few times does not mean those 3 places have a problem, it just tells it's good rule for the general case. So I won't accept using such numbers as a leverage against the few places just for the sake of silencing checkpatch.

Hi,

I just thought there must be a reason that the checkpatch categories findings as "ERROR", "WARNING" and "CHECK".

Sometimes the number does make sense and means the vast majority follow the widely accepted "rule".

Curiously, isn't it the contributor's due diligence to pass checkpatch
in the first place before sending? Should any objection, submit a patch to checkpatch itself, instead of sneaking into the upstream quietly for the sake of "readability".

Quoted 6 lines
Quoted 2 lines

Perhaps there are other approaches to make them more readable without breaking the rule.

Perhaps, but I'm not sure the effort spent to find one is worthwhile investment.

Indeed, that's precisely why it might be worth sacrificing a bit of "readability".

maintainer
#5 lore raw
Quoted 49 lines · Xiang Shen
Quoted 48 lines · Ilpo Järvinen
Quoted 33 lines · Xiang Shen
Quoted 5 lines · Hans de Goede

Review

Quoted 4 lines · Xiang Shen

Fix checkpatch code style errors:

ERROR: do not use assignment in if condition

(quoted diff) +1 -0
+	if ((ke = sparse_keymap_entry_from_scancode(priv->buttons_dev,

event))) {

Quoted 3 lines

Review

Quoted 3 lines

ERROR: do not use assignment in if condition

(quoted diff) +1 -0
+	} else if ((ke =

sparse_keymap_entry_from_scancode(priv->switches_dev, event))) {

Quoted 12 lines
Quoted 2 lines

Thank you for your patch, but this change really does not make the code more readable.

The contrary the suggested changes are making the code harder to read, so NACK.

Note checkpatch is just a tool, sometimes there are good reasons to deviate from the style checks done by checkpatch.

Quoted 8 lines

Next time when submitting a patch to fix checkpatch issues please take a look at the resulting code after the patch and only submit the patch upstream if it actually is an improvement.

Regards,

Hans

Hi Hans,

Quoted 8 lines

Thanks for the feedback.

That's fine if breaking the "rule" is the only way to keep the file readable.

However, there are only three files (x86/sony-laptop.c and x86/dell/dell_rbu.c) out of 273 files in the whole drivers/platform folder that have such an error.

Hi,

Please don't call correct code "error" even if checkpatch may label it as such. The goal is NOT and will never be to have zero checkpatch warnings.

Quoted 8 lines
Quoted 5 lines

The fact that the checkpatch "rule" is broken only a few times does not mean those 3 places have a problem, it just tells it's good rule for the general case. So I won't accept using such numbers as a leverage against the few places just for the sake of silencing checkpatch.

I just thought there must be a reason that the checkpatch categories findings as "ERROR", "WARNING" and "CHECK".

The checkpatch change submitter just picked one of the levels. They're humans too. :-)

Quoted 5 lines

Sometimes the number does make sense and means the vast majority follow the widely accepted "rule".

Curiously, isn't it the contributor's due diligence to pass checkpatch in the first place before sending?

Hey, that code you're changing is not being submitted. We don't want to waste our time on "fixing" checkpatch warnings on existing code when the "fix" results in worse readability that before.

Also, if you would be submitting a patch and checkpatch suggest you to make the patch worse, please don't follow checkpatch's advice even in that case!

Checker tools are there to help find potential issues, not rulebooks. This is often overlooked by many checker tool focused developers and results in low quality patches (there are exceptions too where they developer really tries to understand all the related code to see if the change makes sense / improves things or not).

Quoted 7 lines

Should any objection, submit a patch to
checkpatch itself,
instead of sneaking into the upstream quietly for the sake of "readability".

Quoted 3 lines
Quoted 2 lines

Perhaps there are other approaches to make them more readable without breaking the rule.

Quoted 6 lines
Quoted 3 lines

Perhaps, but I'm not sure the effort spent to find one is worthwhile investment.

Indeed, that's precisely why it might be worth sacrificing a bit of "readability".

Please stop trying to sneak your subpar change in.

NO, this a hard NO from the acting maintainer. We'll not be accepting misguided changes that are to silence ANY checker that should have know better (those checkers will never learn enough to be relied 100% so please stop spreading such illusion).

Signature · 1 line
 i.
author
#6 lore raw
Quoted 77 lines · Ilpo Järvinen
Quoted 49 lines · Xiang Shen
Quoted 48 lines · Ilpo Järvinen
Quoted 33 lines · Xiang Shen
Quoted 5 lines · Hans de Goede

Review

Quoted 4 lines · Xiang Shen

Fix checkpatch code style errors:

ERROR: do not use assignment in if condition

(quoted diff) +1 -0
+	if ((ke = sparse_keymap_entry_from_scancode(priv->buttons_dev,

event))) {

Quoted 3 lines

Review

Quoted 3 lines

ERROR: do not use assignment in if condition

(quoted diff) +1 -0
+	} else if ((ke =

sparse_keymap_entry_from_scancode(priv->switches_dev, event))) {

Quoted 12 lines
Quoted 2 lines

Thank you for your patch, but this change really does not make the code more readable.

The contrary the suggested changes are making the code harder to read, so NACK.

Note checkpatch is just a tool, sometimes there are good reasons to deviate from the style checks done by checkpatch.

Quoted 8 lines

Next time when submitting a patch to fix checkpatch issues please take a look at the resulting code after the patch and only submit the patch upstream if it actually is an improvement.

Regards,

Hans

Hi Hans,

Quoted 8 lines

Thanks for the feedback.

That's fine if breaking the "rule" is the only way to keep the file readable.

However, there are only three files (x86/sony-laptop.c and x86/dell/dell_rbu.c) out of 273 files in the whole drivers/platform folder that have such an error.

Hi,

Please don't call correct code "error" even if checkpatch may label it as such. The goal is NOT and will never be to have zero checkpatch warnings.

Quoted 8 lines
Quoted 5 lines

The fact that the checkpatch "rule" is broken only a few times does not mean those 3 places have a problem, it just tells it's good rule for the general case. So I won't accept using such numbers as a leverage against the few places just for the sake of silencing checkpatch.

I just thought there must be a reason that the checkpatch categories findings as "ERROR", "WARNING" and "CHECK".

The checkpatch change submitter just picked one of the levels. They're humans too. :-)

Quoted 5 lines

Sometimes the number does make sense and means the vast majority follow the widely accepted "rule".

Curiously, isn't it the contributor's due diligence to pass checkpatch in the first place before sending?

Hey, that code you're changing is not being submitted. We don't want to waste our time on "fixing" checkpatch warnings on existing code when the "fix" results in worse readability that before.

Also, if you would be submitting a patch and checkpatch suggest you to make the patch worse, please don't follow checkpatch's advice even in that case!

Quoted 6 lines

Checker tools are there to help find potential issues, not rulebooks. This is often overlooked by many checker tool focused developers and results in low quality patches (there are exceptions too where they developer really tries to understand all the related code to see if the change makes sense / improves things or not).

Hi Ilpo,

I've learned a lot — thanks for the thorough explanation rather than just brushing me off.

The rookies are certainly more likely than the veterans to treat the "rulebooks" as ironclad disciplines.

Quoted 14 lines
Quoted 7 lines

Should any objection, submit a patch to
checkpatch itself,
instead of sneaking into the upstream quietly for the sake of "readability".

Quoted 3 lines
Quoted 2 lines

Perhaps there are other approaches to make them more readable without breaking the rule.

Quoted 6 lines
Quoted 3 lines

Perhaps, but I'm not sure the effort spent to find one is worthwhile investment.

Indeed, that's precisely why it might be worth sacrificing a bit of "readability".

Quoted 7 lines

Please stop trying to sneak your subpar change in.

NO, this a hard NO from the acting maintainer. We'll not be accepting misguided changes that are to silence ANY checker that should have know better (those checkers will never learn enough to be relied 100% so please stop spreading such illusion).

I wish I had known those checking errors were intentionally ignored. I'm putting a full stop here.