From: James Seo Date: Sat, 22 Jul 2023 17:25:13 +0000 (-0700) Subject: hwmon: (hp-wmi-sensors) Get WMI instance count from WMI driver core X-Git-Tag: v6.6.7~2082^2~30 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=10a7a334d3a1f2d888a42a3c956813274ffb8a9c;p=platform%2Fkernel%2Flinux-starfive.git hwmon: (hp-wmi-sensors) Get WMI instance count from WMI driver core Commit 2a2b13ae50cf ("platform/x86: wmi: Allow retrieving the number of WMI object instances") means we no longer need to find this ourselves. Signed-off-by: James Seo Link: https://lore.kernel.org/r/20230722172513.9324-2-james@equiv.tech Signed-off-by: Guenter Roeck --- diff --git a/drivers/hwmon/hp-wmi-sensors.c b/drivers/hwmon/hp-wmi-sensors.c index ebe2fb5..3a99cc5 100644 --- a/drivers/hwmon/hp-wmi-sensors.c +++ b/drivers/hwmon/hp-wmi-sensors.c @@ -435,25 +435,11 @@ static union acpi_object *hp_wmi_get_wobj(const char *guid, u8 instance) /* hp_wmi_wobj_instance_count - find count of WMI object instances */ static u8 hp_wmi_wobj_instance_count(const char *guid) { - u8 hi = HP_WMI_MAX_INSTANCES; - union acpi_object *wobj; - u8 lo = 0; - u8 mid; - - while (lo < hi) { - mid = (lo + hi) / 2; - - wobj = hp_wmi_get_wobj(guid, mid); - if (!wobj) { - hi = mid; - continue; - } + int count; - lo = mid + 1; - kfree(wobj); - } + count = wmi_instance_count(guid); - return lo; + return clamp(count, 0, (int)HP_WMI_MAX_INSTANCES); } static int check_wobj(const union acpi_object *wobj,