aboutsummaryrefslogtreecommitdiff
path: root/drivers/platform
diff options
context:
space:
mode:
authorBarnabás Pőcze <pobrn@protonmail.com>2022-10-05 15:00:39 +0000
committerHans de Goede <hdegoede@redhat.com>2022-11-16 08:48:18 +0100
commitd6fef93258f3b902f5166297b05d72746e16e1f7 (patch)
treeea6e13499835f6b549fc6c960e1c717eafdbae09 /drivers/platform
parenta77272c16041862c5c8d450c8701139887e1bb05 (diff)
platform/x86: huawei-wmi: do not hard-code sizes
Use `sizeof()` and `ARRAY_SIZE()` instead of hard-coding buffer sizes and indices. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Link: https://lore.kernel.org/r/20221005150032.173198-1-pobrn@protonmail.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/huawei-wmi.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/platform/x86/huawei-wmi.c b/drivers/platform/x86/huawei-wmi.c
index 415ccb3a95de..2b48e86448b3 100644
--- a/drivers/platform/x86/huawei-wmi.c
+++ b/drivers/platform/x86/huawei-wmi.c
@@ -323,12 +323,12 @@ static int huawei_wmi_battery_get(int *start, int *end)
u8 ret[0x100];
int err, i;
- err = huawei_wmi_cmd(BATTERY_THRESH_GET, ret, 0x100);
+ err = huawei_wmi_cmd(BATTERY_THRESH_GET, ret, sizeof(ret));
if (err)
return err;
/* Find the last two non-zero values. Return status is ignored. */
- i = 0xff;
+ i = ARRAY_SIZE(ret) - 1;
do {
if (start)
*start = ret[i-1];