mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Add and use supported/unsupported string helper
@ 2026-09-07  8:43 Thorsten Blum
  2026-09-07  8:43 ` [PATCH v2 1/2] lib/string_choices: Add str_supported_unsupported() helper Thorsten Blum
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Thorsten Blum @ 2026-09-07  8:43 UTC (permalink / raw)
  To: Mark Pearson, Derek J. Clark, Henrique de Moraes Holschuh,
	Hans de Goede, Ilpo Järvinen, Kees Cook, Andy Shevchenko
  Cc: platform-driver-x86, ibm-acpi-devel, linux-kernel,
	linux-hardening, Thorsten Blum

Add a shared str_supported_unsupported() helper and use it to replace
thinkpad_acpi's custom implementation.

Changes in v2:
- Add and use str_supported_unsupported() as suggested by Ilpo
- v1: https://lore.kernel.org/r/20260806131549.235170-2-thorsten.blum@linux.dev/

Thorsten Blum (2):
  lib/string_choices: Add str_supported_unsupported() helper
  platform/x86: thinkpad_acpi: Use str_supported_unsupported() helper

 drivers/platform/x86/lenovo/thinkpad_acpi.c | 42 ++++++++-------------
 include/linux/string_choices.h              |  6 +++
 2 files changed, 22 insertions(+), 26 deletions(-)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/2] lib/string_choices: Add str_supported_unsupported() helper
  2026-09-07  8:43 [PATCH v2 0/2] Add and use supported/unsupported string helper Thorsten Blum
@ 2026-09-07  8:43 ` Thorsten Blum
  2026-09-07 10:31   ` Andy Shevchenko
  2026-09-07 11:12   ` Thorsten Blum
  2026-09-07  8:43 ` [PATCH v2 2/2] platform/x86: thinkpad_acpi: Use " Thorsten Blum
  2026-09-07 10:31 ` [PATCH v2 0/2] Add and use supported/unsupported string helper Andy Shevchenko
  2 siblings, 2 replies; 7+ messages in thread
From: Thorsten Blum @ 2026-09-07  8:43 UTC (permalink / raw)
  To: Mark Pearson, Derek J. Clark, Henrique de Moraes Holschuh,
	Hans de Goede, Ilpo Järvinen, Kees Cook, Andy Shevchenko
  Cc: platform-driver-x86, ibm-acpi-devel, linux-kernel,
	linux-hardening, Thorsten Blum

Add str_supported_unsupported() to return "supported" or "unsupported"
depending on the boolean argument. Also add the inverse
str_unsupported_supported().

Signed-off-by: Thorsten Blum <blum@kernel.org>
---
 include/linux/string_choices.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/string_choices.h b/include/linux/string_choices.h
index ee84087d4b26..a2eba454004f 100644
--- a/include/linux/string_choices.h
+++ b/include/linux/string_choices.h
@@ -65,6 +65,12 @@ static inline const char *str_read_write(bool v)
 }
 #define str_write_read(v)		str_read_write(!(v))
 
+static inline const char *str_supported_unsupported(bool v)
+{
+	return v ? "supported" : "unsupported";
+}
+#define str_unsupported_supported(v)	str_supported_unsupported(!(v))
+
 static inline const char *str_true_false(bool v)
 {
 	return v ? "true" : "false";

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 2/2] platform/x86: thinkpad_acpi: Use str_supported_unsupported() helper
  2026-09-07  8:43 [PATCH v2 0/2] Add and use supported/unsupported string helper Thorsten Blum
  2026-09-07  8:43 ` [PATCH v2 1/2] lib/string_choices: Add str_supported_unsupported() helper Thorsten Blum
@ 2026-09-07  8:43 ` Thorsten Blum
  2026-09-07 10:33   ` Andy Shevchenko
  2026-09-07 10:31 ` [PATCH v2 0/2] Add and use supported/unsupported string helper Andy Shevchenko
  2 siblings, 1 reply; 7+ messages in thread
From: Thorsten Blum @ 2026-09-07  8:43 UTC (permalink / raw)
  To: Mark Pearson, Derek J. Clark, Henrique de Moraes Holschuh,
	Hans de Goede, Ilpo Järvinen, Kees Cook, Andy Shevchenko
  Cc: platform-driver-x86, ibm-acpi-devel, linux-kernel,
	linux-hardening, Thorsten Blum

Remove the local str_supported() function and use the common
str_supported_unsupported() helper.

Debug messages now use "unsupported" instead of "not supported".

Signed-off-by: Thorsten Blum <blum@kernel.org>
---
 drivers/platform/x86/lenovo/thinkpad_acpi.c | 42 ++++++++-------------
 1 file changed, 16 insertions(+), 26 deletions(-)

diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
index 1082c36ae723..bda192d9261d 100644
--- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
+++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
@@ -456,9 +456,7 @@ do {									\
 
 #ifdef CONFIG_THINKPAD_ACPI_DEBUG
 #define vdbg_printk dbg_printk
-static const char *str_supported(int is_supported);
 #else
-static inline const char *str_supported(int is_supported) { return ""; }
 #define vdbg_printk(a_dbg_level, format, arg...)	\
 	do { if (0) no_printk(format, ##arg); } while (0)
 #endif
@@ -3338,7 +3336,7 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
 
 	vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY,
 		"hotkeys are %s\n",
-		str_supported(tp_features.hotkey));
+		str_supported_unsupported(tp_features.hotkey));
 
 	if (!tp_features.hotkey)
 		return -ENODEV;
@@ -3415,7 +3413,7 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
 
 	vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY,
 		"hotkey masks are %s\n",
-		str_supported(tp_features.hotkey_mask));
+		str_supported_unsupported(tp_features.hotkey_mask));
 
 	/* Init hotkey_all_mask if not initialized yet */
 	if (!tp_features.hotkey_mask && !hotkey_all_mask &&
@@ -4327,7 +4325,7 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm)
 
 	vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL,
 		"bluetooth is %s, status 0x%02x\n",
-		str_supported(tp_features.bluetooth),
+		str_supported_unsupported(tp_features.bluetooth),
 		status);
 
 #ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
@@ -4506,7 +4504,7 @@ static int __init wan_init(struct ibm_init_struct *iibm)
 
 	vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL,
 		"wan is %s, status 0x%02x\n",
-		str_supported(tp_features.wan),
+		str_supported_unsupported(tp_features.wan),
 		status);
 
 #ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
@@ -4634,7 +4632,7 @@ static int __init uwb_init(struct ibm_init_struct *iibm)
 
 	vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL,
 		"uwb is %s, status 0x%02x\n",
-		str_supported(tp_features.uwb),
+		str_supported_unsupported(tp_features.uwb),
 		status);
 
 #ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
@@ -4742,7 +4740,7 @@ static int __init video_init(struct ibm_init_struct *iibm)
 		video_supported = TPACPI_VIDEO_NEW;
 
 	vdbg_printk(TPACPI_DBG_INIT, "video is %s, mode %d\n",
-		str_supported(video_supported != TPACPI_VIDEO_NONE),
+		str_supported_unsupported(video_supported != TPACPI_VIDEO_NONE),
 		video_supported);
 
 	return (video_supported != TPACPI_VIDEO_NONE) ? 0 : -ENODEV;
@@ -5340,8 +5338,8 @@ static int __init light_init(struct ibm_init_struct *iibm)
 			acpi_evalf(ec_handle, NULL, "KBLT", "qv");
 
 	vdbg_printk(TPACPI_DBG_INIT, "light is %s, light status is %s\n",
-		str_supported(tp_features.light),
-		str_supported(tp_features.light_status));
+		str_supported_unsupported(tp_features.light),
+		str_supported_unsupported(tp_features.light_status));
 
 	if (!tp_features.light)
 		return -ENODEV;
@@ -5458,7 +5456,7 @@ static int __init cmos_init(struct ibm_init_struct *iibm)
 	TPACPI_ACPIHANDLE_INIT(cmos);
 
 	vdbg_printk(TPACPI_DBG_INIT, "cmos commands are %s\n",
-		    str_supported(cmos_handle != NULL));
+		    str_supported_unsupported(cmos_handle));
 
 	return cmos_handle ? 0 : -ENODEV;
 }
@@ -5803,7 +5801,8 @@ static int __init led_init(struct ibm_init_struct *iibm)
 	}
 
 	vdbg_printk(TPACPI_DBG_INIT, "LED commands are %s, mode %d\n",
-		str_supported(led_supported), led_supported);
+		str_supported_unsupported(led_supported != TPACPI_LED_NONE),
+		led_supported);
 
 	if (led_supported == TPACPI_LED_NONE)
 		return -ENODEV;
@@ -5924,7 +5923,7 @@ static int __init beep_init(struct ibm_init_struct *iibm)
 	TPACPI_ACPIHANDLE_INIT(beep);
 
 	vdbg_printk(TPACPI_DBG_INIT, "beep is %s\n",
-		str_supported(beep_handle != NULL));
+		str_supported_unsupported(beep_handle));
 
 	quirks = tpacpi_check_quirks(beep_quirk_table,
 				     ARRAY_SIZE(beep_quirk_table));
@@ -6374,7 +6373,7 @@ static int __init thermal_init(struct ibm_init_struct *iibm)
 	thermal_read_mode = thermal_read_mode_check();
 
 	vdbg_printk(TPACPI_DBG_INIT, "thermal is %s, mode %d\n",
-		str_supported(thermal_read_mode != TPACPI_THERMAL_NONE),
+		str_supported_unsupported(thermal_read_mode != TPACPI_THERMAL_NONE),
 		thermal_read_mode);
 
 	return thermal_read_mode != TPACPI_THERMAL_NONE ? 0 : -ENODEV;
@@ -7596,7 +7595,7 @@ static int __init volume_init(struct ibm_init_struct *iibm)
 
 	vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_MIXER,
 			"mute is supported, volume control is %s\n",
-			str_supported(!tp_features.mixer_no_level_control));
+			str_supported_unsupported(!tp_features.mixer_no_level_control));
 
 	if (software_mute_requested && volume_set_software_mute(true) == 0) {
 		software_mute_active = true;
@@ -8993,8 +8992,8 @@ static int __init fan_init(struct ibm_init_struct *iibm)
 
 	vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_FAN,
 		"fan is %s, modes %d, %d\n",
-		str_supported(fan_status_access_mode != TPACPI_FAN_NONE ||
-		  fan_control_access_mode != TPACPI_FAN_WR_NONE),
+		str_supported_unsupported(fan_status_access_mode != TPACPI_FAN_NONE ||
+					  fan_control_access_mode != TPACPI_FAN_WR_NONE),
 		fan_status_access_mode, fan_control_access_mode);
 
 	/* fan control master switch */
@@ -11632,15 +11631,6 @@ static struct proc_dir_entry *proc_dir;
 
 static bool force_load;
 
-#ifdef CONFIG_THINKPAD_ACPI_DEBUG
-static const char * __init str_supported(int is_supported)
-{
-	static char text_unsupported[] __initdata = "not supported";
-
-	return (is_supported) ? &text_unsupported[4] : &text_unsupported[0];
-}
-#endif /* CONFIG_THINKPAD_ACPI_DEBUG */
-
 static struct dentry *tpacpi_dbg;
 static void tpacpi_debugfs_init(void)
 {

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] lib/string_choices: Add str_supported_unsupported() helper
  2026-09-07  8:43 ` [PATCH v2 1/2] lib/string_choices: Add str_supported_unsupported() helper Thorsten Blum
@ 2026-09-07 10:31   ` Andy Shevchenko
  2026-09-07 11:12   ` Thorsten Blum
  1 sibling, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2026-09-07 10:31 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Mark Pearson, Derek J. Clark, Henrique de Moraes Holschuh,
	Hans de Goede, Ilpo Järvinen, Kees Cook, Andy Shevchenko,
	platform-driver-x86, ibm-acpi-devel, linux-kernel,
	linux-hardening

On Mon, Sep 7, 2026 at 11:44 AM Thorsten Blum <blum@kernel.org> wrote:
>
> Add str_supported_unsupported() to return "supported" or "unsupported"
> depending on the boolean argument. Also add the inverse
> str_unsupported_supported().

Reviewed-by: Andy Shevchenko <andy@kernel.org>

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 0/2] Add and use supported/unsupported string helper
  2026-09-07  8:43 [PATCH v2 0/2] Add and use supported/unsupported string helper Thorsten Blum
  2026-09-07  8:43 ` [PATCH v2 1/2] lib/string_choices: Add str_supported_unsupported() helper Thorsten Blum
  2026-09-07  8:43 ` [PATCH v2 2/2] platform/x86: thinkpad_acpi: Use " Thorsten Blum
@ 2026-09-07 10:31 ` Andy Shevchenko
  2 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2026-09-07 10:31 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Mark Pearson, Derek J. Clark, Henrique de Moraes Holschuh,
	Hans de Goede, Ilpo Järvinen, Kees Cook, Andy Shevchenko,
	platform-driver-x86, ibm-acpi-devel, linux-kernel,
	linux-hardening

On Mon, Sep 7, 2026 at 11:44 AM Thorsten Blum <blum@kernel.org> wrote:
>
> Add a shared str_supported_unsupported() helper and use it to replace
> thinkpad_acpi's custom implementation.
>
> Changes in v2:
> - Add and use str_supported_unsupported() as suggested by Ilpo

Suggested-by?

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 2/2] platform/x86: thinkpad_acpi: Use str_supported_unsupported() helper
  2026-09-07  8:43 ` [PATCH v2 2/2] platform/x86: thinkpad_acpi: Use " Thorsten Blum
@ 2026-09-07 10:33   ` Andy Shevchenko
  0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2026-09-07 10:33 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Mark Pearson, Derek J. Clark, Henrique de Moraes Holschuh,
	Hans de Goede, Ilpo Järvinen, Kees Cook, Andy Shevchenko,
	platform-driver-x86, ibm-acpi-devel, linux-kernel,
	linux-hardening

On Mon, Sep 7, 2026 at 11:44 AM Thorsten Blum <blum@kernel.org> wrote:
>
> Remove the local str_supported() function and use the common
> str_supported_unsupported() helper.
>
> Debug messages now use "unsupported" instead of "not supported".

Reviewed-by: Andy Shevchenko <andy@kernel.org>

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] lib/string_choices: Add str_supported_unsupported() helper
  2026-09-07  8:43 ` [PATCH v2 1/2] lib/string_choices: Add str_supported_unsupported() helper Thorsten Blum
  2026-09-07 10:31   ` Andy Shevchenko
@ 2026-09-07 11:12   ` Thorsten Blum
  1 sibling, 0 replies; 7+ messages in thread
From: Thorsten Blum @ 2026-09-07 11:12 UTC (permalink / raw)
  To: Mark Pearson, Derek J. Clark, Henrique de Moraes Holschuh,
	Hans de Goede, Ilpo Järvinen, Kees Cook, Andy Shevchenko
  Cc: platform-driver-x86, ibm-acpi-devel, linux-kernel, linux-hardening

On Mon, Sep 07, 2026 at 10:43:20AM +0200, Thorsten Blum wrote:
> Add str_supported_unsupported() to return "supported" or "unsupported"
> depending on the boolean argument. Also add the inverse
> str_unsupported_supported().
> 
> Signed-off-by: Thorsten Blum <blum@kernel.org>
> ---
>  include/linux/string_choices.h | 6 ++++++
>  1 file changed, 6 insertions(+)

Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-09-07 11:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-07  8:43 [PATCH v2 0/2] Add and use supported/unsupported string helper Thorsten Blum
2026-09-07  8:43 ` [PATCH v2 1/2] lib/string_choices: Add str_supported_unsupported() helper Thorsten Blum
2026-09-07 10:31   ` Andy Shevchenko
2026-09-07 11:12   ` Thorsten Blum
2026-09-07  8:43 ` [PATCH v2 2/2] platform/x86: thinkpad_acpi: Use " Thorsten Blum
2026-09-07 10:33   ` Andy Shevchenko
2026-09-07 10:31 ` [PATCH v2 0/2] Add and use supported/unsupported string helper Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®