Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1394618rwr; Wed, 26 Apr 2023 14:31:17 -0700 (PDT) X-Google-Smtp-Source: AKy350YNmavTsJwvGzlfXnNGoD2BKfItC3Fm7PhvAXUY0v7bKrAjmQYEPKaeg+IPNpULfL+aMB3q X-Received: by 2002:a05:6a20:3944:b0:f5:e533:4dbf with SMTP id r4-20020a056a20394400b000f5e5334dbfmr11982152pzg.55.1682544676909; Wed, 26 Apr 2023 14:31:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682544676; cv=none; d=google.com; s=arc-20160816; b=sDwrr6Cos0LJom8QTyQ47I7ZHUyS77icHvFDrqvOz62Sg7nGG7M0UZs/ROvMtNCIlB KXgoXeiiBU4CcVoWbB5otsbjTHWI5oYeCStx6OxU1CmhYTMmlG12K14pECSBGYpMuRzz 9NeIsC2o+jDspeGk5KJ6Jw08Q6ooH8fbzRh3VEgR0zcDolsLTkg0JAUmUkUctnVfTIbD DHC3Bf7Mtkv0nfdXKHT/zqjEvJb3LEGeqaZqZ+s5Kl/IIIn02oVsAr11XJigEGKJaw/K xes4bbTcNwcpsXvrJedbu1U2shmUd6sWAj0wCtEM9GaQxIWWCr02ei1V1t5B1U/9TO/T ZBDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0N0VoagqnDF2dXw109/DOG5Y4839yAXWcDIwsE7XeQs=; b=nVtYTCTA3Xy2ndz181++ltAmetArnnIgijBwhFV0+AXDeCSbdx1hBKW1dR9ZEZENiY r5gFzW01JP7yOk3T9TYW9jlnZHTNmX8KBdQrR2NS9doz2YztYQ1KvK3tb1gmsSuI/ONP ODuR+p4ZQPc4E24FdAuELZ2Wga3jblxTHYCOnTTxVSIkbje0WgkF4J6yNrMGLmPg6z6b 5c/RVI8/i8/Ht/AL5YNwBigDAIRPugfF6HZuVR9JIp7he1FBWDShCe+19sQBBQPyYmzw O4JeYeU/+3CeknTN10RAu3fbSj4p+CiYWTEu9pp0DUswajaLx64O9qJ8Q0Zq4RpYIsAY DczQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=d9hJlwlL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n128-20020a634086000000b0051b9a1e823csi16235301pga.137.2023.04.26.14.31.02; Wed, 26 Apr 2023 14:31:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=d9hJlwlL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239926AbjDZV3j (ORCPT + 99 others); Wed, 26 Apr 2023 17:29:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239910AbjDZV3Z (ORCPT ); Wed, 26 Apr 2023 17:29:25 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B5243ABD; Wed, 26 Apr 2023 14:29:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1682544539; i=w_armin@gmx.de; bh=w0oARY4CbAc6zKzf6JtPUqR+03JXON4Kw0RqkAkLgZI=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=d9hJlwlLij5eF36umbIBVFK1ufeo6ydGXvSRfiW9vjLWfbFReHH0jCwDhoQwwDvGK pMBytG46itblNlVvH3+58y5xaM0MHrGYva3Qu3ZSxxMielMa0A9nNYiChTwDWaOiNY tNn5+TpVEhayv8D4AhC06Ibjsctg6InLVrTrqrhVb4vji8nHV0f4HoaypXuVSBsGj/ bh6RruEPeGaGqNPPBLUJN5jXQRcNjwf0xYMnn4VZFtwht08nN2HvWV0cGBlEMcwC9b RNas4EDYqupdX6DL234VQt/f/TD5HNAP9UCzEtBi9ORaIJ0C/8jhADFsR7n0/ZDGLz M40As4pDXb1rA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from esprimo-mx.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MDywu-1q1iKV2b6i-009ybF; Wed, 26 Apr 2023 23:28:59 +0200 From: Armin Wolf To: hdegoede@redhat.com, markgross@kernel.org Cc: Mario.Limonciello@amd.com, prasanth.ksr@dell.com, jorgealtxwork@gmail.com, james@equiv.tech, Dell.Client.Kernel@dell.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC v2 2/2] platform/x86: dell-sysman: Improve instance detection Date: Wed, 26 Apr 2023 23:28:48 +0200 Message-Id: <20230426212848.108562-3-W_Armin@gmx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230426212848.108562-1-W_Armin@gmx.de> References: <20230426212848.108562-1-W_Armin@gmx.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:4q9pu12CWhdJrKzj8Vw67SJGG5tca+ZIz+j1qkuxE64mtysyVX5 5Z+eFZJwSU2ykCfhbkR4+fj+vzfNeG2U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r3OecMk2ciGFRvi0P0t7W/4wUf2Sx0wPIDP/Zb2lJYyr+MpmDzwRXhKzoJfoOFqwpaILheP +m/pOPgVkBLzOoCiu6QA2PF5ueM= X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The WMI driver core already knows how many WMI object instances are available, use this information instead of probing the WMI object manually. Compile-tested only. Signed-off-by: Armin Wolf =2D-- .../platform/x86/dell/dell-wmi-sysman/sysman.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c b/drivers/= platform/x86/dell/dell-wmi-sysman/sysman.c index 0285b47d99d1..526d60b510bb 100644 =2D-- a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +++ b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c @@ -7,6 +7,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -303,16 +304,14 @@ union acpi_object *get_wmiobj_pointer(int instance_i= d, const char *guid_string) */ int get_instance_count(const char *guid_string) { - union acpi_object *wmi_obj =3D NULL; - int i =3D 0; + acpi_status status; + u8 instance_count; - do { - kfree(wmi_obj); - wmi_obj =3D get_wmiobj_pointer(i, guid_string); - i++; - } while (wmi_obj); + status =3D wmi_instance_count(guid_string, &instance_count); + if (ACPI_FAILURE(status)) + return 0; - return (i-1); + return instance_count; } /** =2D- 2.30.2