All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] platform/x86: thinkpad_acpi: Use bool for str_supported() parameter
@ 2026-08-06 13:15 Thorsten Blum
  2026-08-18 13:25 ` Ilpo Järvinen
  0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Blum @ 2026-08-06 13:15 UTC (permalink / raw)
  To: Mark Pearson, Derek J. Clark, Henrique de Moraes Holschuh,
	Hans de Goede, Ilpo Järvinen
  Cc: Thorsten Blum, platform-driver-x86, ibm-acpi-devel, linux-kernel

Make str_supported() take a bool, define it inline, and return string
literals directly. Use a single inline definition for both debug and
non-debug builds.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 drivers/platform/x86/lenovo/thinkpad_acpi.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
index 445e1403308e..022353f95cab 100644
--- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
+++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
@@ -448,11 +448,14 @@ do {									\
 		       __func__, ##arg);				\
 } while (0)
 
+static inline const char * __init str_supported(bool is_supported)
+{
+	return is_supported ? "supported" : "not supported";
+}
+
 #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
@@ -5798,7 +5801,7 @@ 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(led_supported != TPACPI_LED_NONE), led_supported);
 
 	if (led_supported == TPACPI_LED_NONE)
 		return -ENODEV;
@@ -11515,15 +11518,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 related	[flat|nested] 3+ messages in thread

* Re: [PATCH] platform/x86: thinkpad_acpi: Use bool for str_supported() parameter
  2026-08-06 13:15 [PATCH] platform/x86: thinkpad_acpi: Use bool for str_supported() parameter Thorsten Blum
@ 2026-08-18 13:25 ` Ilpo Järvinen
  2026-08-18 13:34   ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Ilpo Järvinen @ 2026-08-18 13:25 UTC (permalink / raw)
  To: Thorsten Blum, Andy Shevchenko
  Cc: Mark Pearson, Derek J. Clark, Henrique de Moraes Holschuh,
	Hans de Goede, Ilpo Järvinen, platform-driver-x86,
	ibm-acpi-devel, LKML

On Thu, 6 Aug 2026, Thorsten Blum wrote:

> Make str_supported() take a bool, define it inline, and return string
> literals directly. Use a single inline definition for both debug and
> non-debug builds.
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  drivers/platform/x86/lenovo/thinkpad_acpi.c | 18 ++++++------------
>  1 file changed, 6 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> index 445e1403308e..022353f95cab 100644
> --- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
> +++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> @@ -448,11 +448,14 @@ do {									\
>  		       __func__, ##arg);				\
>  } while (0)
>  
> +static inline const char * __init str_supported(bool is_supported)
> +{
> +	return is_supported ? "supported" : "not supported";
> +}

This certainly looks something that should be in linux/string_choices.h. 
I'm pretty surprised it isn't already there actually.

Not sure about how to name it though, str_supported_not_supported() a bit 
repetitive. Andy?

-- 
 i.

> +
>  #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
> @@ -5798,7 +5801,7 @@ 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(led_supported != TPACPI_LED_NONE), led_supported);
>  
>  	if (led_supported == TPACPI_LED_NONE)
>  		return -ENODEV;
> @@ -11515,15 +11518,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] 3+ messages in thread

* Re: [PATCH] platform/x86: thinkpad_acpi: Use bool for str_supported() parameter
  2026-08-18 13:25 ` Ilpo Järvinen
@ 2026-08-18 13:34   ` Andy Shevchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2026-08-18 13:34 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: Thorsten Blum, Mark Pearson, Derek J. Clark,
	Henrique de Moraes Holschuh, Hans de Goede, platform-driver-x86,
	ibm-acpi-devel, LKML

On Tue, Aug 18, 2026 at 04:25:21PM +0300, Ilpo Järvinen wrote:
> On Thu, 6 Aug 2026, Thorsten Blum wrote:
> 
> > Make str_supported() take a bool, define it inline, and return string
> > literals directly. Use a single inline definition for both debug and
> > non-debug builds.

> > +static inline const char * __init str_supported(bool is_supported)
> > +{
> > +	return is_supported ? "supported" : "not supported";
> > +}
> 
> This certainly looks something that should be in linux/string_choices.h. 
> I'm pretty surprised it isn't already there actually.
> 
> Not sure about how to name it though, str_supported_not_supported() a bit 
> repetitive. Andy?

Is it part of ABI? Otherwise I would rather see str_supported_unsupported().

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2026-08-18 13:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-06 13:15 [PATCH] platform/x86: thinkpad_acpi: Use bool for str_supported() parameter Thorsten Blum
2026-08-18 13:25 ` Ilpo Järvinen
2026-08-18 13:34   ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.