[PATCH] platform/x86: think-lmi: Use ARRAY_SIZE() in tlmi_errstr_to_err()

Thorsten Blum posted 1 patch 1 month, 2 weeks ago
drivers/platform/x86/lenovo/think-lmi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] platform/x86: think-lmi: Use ARRAY_SIZE() in tlmi_errstr_to_err()
Posted by Thorsten Blum 1 month, 2 weeks ago
Use the ARRAY_SIZE() helper to simplify tlmi_errstr_to_err().

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 drivers/platform/x86/lenovo/think-lmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/lenovo/think-lmi.c b/drivers/platform/x86/lenovo/think-lmi.c
index 26ee6ab34a15..81ab6aafee47 100644
--- a/drivers/platform/x86/lenovo/think-lmi.c
+++ b/drivers/platform/x86/lenovo/think-lmi.c
@@ -249,7 +249,7 @@ static int tlmi_errstr_to_err(const char *errstr)
 {
 	int i;
 
-	for (i = 0; i < sizeof(tlmi_errs)/sizeof(struct tlmi_err_codes); i++) {
+	for (i = 0; i < ARRAY_SIZE(tlmi_errs); i++) {
 		if (!strcmp(tlmi_errs[i].err_str, errstr))
 			return tlmi_errs[i].err_code;
 	}
Re: [PATCH] platform/x86: think-lmi: Use ARRAY_SIZE() in tlmi_errstr_to_err()
Posted by Ilpo Järvinen 1 week, 4 days ago
On Sat, 15 Aug 2026 11:34:32 +0200, Thorsten Blum wrote:

> Use the ARRAY_SIZE() helper to simplify tlmi_errstr_to_err().

Thank you for your contribution, it has been applied to my local
review-ilpo-next branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-next branch only once I've pushed my
local branch there, which might take a while.

FYI [if applicable to your patch], as per Linus' policy change, also
fixes are mostly routed through for-next unless the fix is for a
commit introduced in the most recent cycle or is clearly a regression
fix.

The list of commits applied:
[1/1] platform/x86: think-lmi: Use ARRAY_SIZE() in tlmi_errstr_to_err()
      commit: 2ba3e60e4e073b48abde8e787fe6fffaacdc4007

--
 i.
Re: [PATCH] platform/x86: think-lmi: Use ARRAY_SIZE() in tlmi_errstr_to_err()
Posted by Mark Pearson 1 month, 1 week ago
On Sat, Aug 15, 2026, at 5:34 AM, Thorsten Blum wrote:
> Use the ARRAY_SIZE() helper to simplify tlmi_errstr_to_err().
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  drivers/platform/x86/lenovo/think-lmi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/lenovo/think-lmi.c 
> b/drivers/platform/x86/lenovo/think-lmi.c
> index 26ee6ab34a15..81ab6aafee47 100644
> --- a/drivers/platform/x86/lenovo/think-lmi.c
> +++ b/drivers/platform/x86/lenovo/think-lmi.c
> @@ -249,7 +249,7 @@ static int tlmi_errstr_to_err(const char *errstr)
>  {
>  	int i;
> 
> -	for (i = 0; i < sizeof(tlmi_errs)/sizeof(struct tlmi_err_codes); i++) {
> +	for (i = 0; i < ARRAY_SIZE(tlmi_errs); i++) {
>  		if (!strcmp(tlmi_errs[i].err_str, errstr))
>  			return tlmi_errs[i].err_code;
>  	}

Thanks - looks good to me
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Mark