Skip to contentSkip to conversation

platform/x86: intel-hid: Use string_choices API instead of ternary operator

PATCH In review Andy Shevchenko 3 participants 3 messages Aug 21, 2024 – Aug 26, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: intel-hid: Use string_choices API instead of ternary operator

Use modern string_choices API instead of manually determining the output using ternary operator.

---
 drivers/platform/x86/intel/hid.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/platform/x86/intel/hid.c +3 -4
index 10cd65497cc1..445e7a59beb4 100644
@@ -13,6 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/string_choices.h>
 #include <linux/suspend.h>
 #include "../dual_accel_detect.h"
 
@@ -331,10 +332,8 @@ static int intel_hid_set_enable(struct device *device, bool enable)
 	acpi_handle handle = ACPI_HANDLE(device);
 
 	/* Enable|disable features - power button is always enabled */
-	if (!intel_hid_execute_method(handle, INTEL_HID_DSM_HDSM_FN,
-				      enable)) {
-		dev_warn(device, "failed to %sable hotkeys\n",
-			 enable ? "en" : "dis");
+	if (!intel_hid_execute_method(handle, INTEL_HID_DSM_HDSM_FN, enable)) {
+		dev_warn(device, "failed to %s hotkeys\n", str_enable_disable(enable));
 		return -EIO;
 	}
 
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 24 lines · Andy Shevchenko

Use modern string_choices API instead of manually determining the output using ternary operator.

---
 drivers/platform/x86/intel/hid.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/platform/x86/intel/hid.c +1 -0
index 10cd65497cc1..445e7a59beb4 100644
@@ -13,6 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/string_choices.h>
 #include <linux/suspend.h>
 #include "../dual_accel_detect.h"
 
@@ -331,10 +332,8 @@ static int intel_hid_set_enable(struct device *device, bool enable)
 	acpi_handle handle = ACPI_HANDLE(device);
 

drivers/platform/x86/intel/hid.c static int intel_hid_set_enable(struct device *device, bool enable) · line 339

Quoted 10 lines
drivers/platform/x86/intel/hid.c +2 -4
 	/* Enable|disable features - power button is always enabled */
-	if (!intel_hid_execute_method(handle, INTEL_HID_DSM_HDSM_FN,
-				      enable)) {
-		dev_warn(device, "failed to %sable hotkeys\n",
-			 enable ? "en" : "dis");
+	if (!intel_hid_execute_method(handle, INTEL_HID_DSM_HDSM_FN, enable)) {
+		dev_warn(device, "failed to %s hotkeys\n", str_enable_disable(enable));
 		return -EIO;
 	}
 
Signature · 1 line
 i.
#2 lore raw
In reply to Andy Shevchenko

Hi,

Quoted 4 lines · Andy Shevchenko

Use modern string_choices API instead of manually determining the output using ternary operator.

Thank you for your patch, I've applied this patch to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.

Regards,

Hans

Quoted 29 lines
---
 drivers/platform/x86/intel/hid.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/platform/x86/intel/hid.c +3 -4
index 10cd65497cc1..445e7a59beb4 100644
@@ -13,6 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/string_choices.h>
 #include <linux/suspend.h>
 #include "../dual_accel_detect.h"
 
@@ -331,10 +332,8 @@ static int intel_hid_set_enable(struct device *device, bool enable)
 	acpi_handle handle = ACPI_HANDLE(device);
 
 	/* Enable|disable features - power button is always enabled */
-	if (!intel_hid_execute_method(handle, INTEL_HID_DSM_HDSM_FN,
-				      enable)) {
-		dev_warn(device, "failed to %sable hotkeys\n",
-			 enable ? "en" : "dis");
+	if (!intel_hid_execute_method(handle, INTEL_HID_DSM_HDSM_FN, enable)) {
+		dev_warn(device, "failed to %s hotkeys\n", str_enable_disable(enable));
 		return -EIO;
 	}