platform/x86: thinkpad_acpi: Use bool for str_supported() parameter
Subsystems (3)
PATCH 1/1 platform/x86: thinkpad_acpi: Use bool for str_supported() parameter
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.
--- drivers/platform/x86/lenovo/thinkpad_acpi.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/platform/x86/lenovo/thinkpad_acpi.c +6 -12
@@ -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 ) {
Ilpo Järvinen
maintainerQuoted 14 lines · Thorsten Blum
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 <[email protected]>--- drivers/platform/x86/lenovo/thinkpad_acpi.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)drivers/platform/x86/lenovo/thinkpad_acpi.c +0
-0
drivers/platform/x86/lenovo/thinkpad_acpi.c do { \ · line 454
Quoted 7 lines
drivers/platform/x86/lenovo/thinkpad_acpi.c +4
-0@@ -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?
Signature · 1 line
i.
Quoted 35 lines
drivers/platform/x86/lenovo/thinkpad_acpi.c +2
-12+#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 ) {
Quoted 14 lines · Ilpo Järvinen
drivers/platform/x86/lenovo/thinkpad_acpi.c do { \ · line 454
Quoted 8 lines · Thorsten Blum
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.drivers/platform/x86/lenovo/thinkpad_acpi.c +4
-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.
Quoted 2 lines
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().
Signature · 2 lines
With Best Regards, Andy Shevchenko