Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1284084rwr; Wed, 26 Apr 2023 12:37:45 -0700 (PDT) X-Google-Smtp-Source: AKy350YKcC0Up+4BJ34pGCUWoUEguHLuGJJSYtJYME9oWVD1lhlXzXmXgIBl2GcEF6bTG7vKiENT X-Received: by 2002:a05:6a20:4281:b0:f0:7ac1:ea61 with SMTP id o1-20020a056a20428100b000f07ac1ea61mr28212083pzj.6.1682537865280; Wed, 26 Apr 2023 12:37:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682537865; cv=none; d=google.com; s=arc-20160816; b=MjurhCexmTfYq1DPpS7pjPmBEg/4lBZNf+dzYKIrvKjAY2AQZuMBbd3R48g0hHP7bE thYeFnu3gW3I1nbbJoQKjRf8eRt3Qw7UBOdqBlvsggGdxkG0Q/EUlKnjwZeVfMUL0IqE T4f0SbTDG0/sJK4+6R1bnc1EClQ8DT+tKWFBjZAUF8WBVB9SyhPWLQ1w659ALstxEhg8 NcWdjOcqWyMAYi+LvU0YIjKSReNaAuryWoMW7AhgcOVPc9j2yuoOL2tWsnaicg8+lve7 V4FwRJW84NXhuCKvRQGu0vG2pe5X57cJVsl8p88MBOizTTlVF47AOnZ7LTiUMzgE/jia mKxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=wtNMCzYA3pH9kL+DBdmzbkxmwaAG28hVOkJw+L2ligo=; b=tks/Bft3sFz5EkdSxrxqy7c1HDgvnQqsSIGAsDisljMqZULbVBTXLIGcoa+SCxQRnZ EDNXCsvhQZPlljTeofE1DOCtyiuvo++ihIfSWLMXHX5PjwxVzF63NMpR1UWBNNrJHDOl 5ZOUj2lDgv9QcuC3WWIUJYli1FErL6y+3/sZGX9PM1mNfLH9NYvPKj+KziLnwraJAJ1X lX2FdTymtCtb2ATvHIUj6WHu1u0H4lRZj8CHhc4yGSkpAIHtzIZDpY55oPhKs6PPI5e4 e/w61yDvlASnIh+cPOSG+rHF3mO2KFzfPKZuTfqzhug41ZfMPMNEmVkx6OPdQ5YNxPBg 8vRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b="TejFsH/6"; 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 q9-20020a632a09000000b00524f1f0d020si12273188pgq.465.2023.04.26.12.37.33; Wed, 26 Apr 2023 12:37:45 -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="TejFsH/6"; 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 S236239AbjDZTf6 (ORCPT + 99 others); Wed, 26 Apr 2023 15:35:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234139AbjDZTf5 (ORCPT ); Wed, 26 Apr 2023 15:35:57 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEB72114; Wed, 26 Apr 2023 12:35:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1682537734; i=w_armin@gmx.de; bh=XUyH3MfpE05wPAy94z/OMdVQELABtgu+fF1W2bG9JFE=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=TejFsH/6s5qsgGmRxhUaCTudQowayTMcrbFkJX8pL0zm0cpTuVu5O6Kn5I9FZdX8W 4MgewEr3Wf46200+6QAAZ7+1CvSRcVBu9Z5PPnHpmGga8glEgvirsR3yoCMVtnt/Rq 6VBZkN2IKWJfy1Irfh1vSQON9dxvKOsZUWwVF0cZT/lkSqruQyL+t5f4D1SEkBZq1+ VKrlKFSF7DoRulTcVCmNyK39atzxkWTxkcBVMLQ4mGTuHpUpQJ1qPGqjWjuw6ReNKa m1v5J4h+gO4IvsVja0qDhPCYmPA9FrsE5I9pxh5qzkj9PQrbaZgL2P0iajDBceWdwc WVnr/FXfqbGNQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.0.14] ([141.30.226.119]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MKsj7-1pYhRL1mRB-00LEfw; Wed, 26 Apr 2023 21:35:34 +0200 Subject: Re: [PATCH v3] hwmon: add HP WMI Sensors driver To: James Seo Cc: Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230424100459.41672-1-james@equiv.tech> From: Armin Wolf Message-ID: <30339393-0ba2-9788-6ad8-98c89afc6994@gmx.de> Date: Wed, 26 Apr 2023 21:35:33 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Provags-ID: V03:K1:JICnlOZNxItB8HUgNhCGxiBjBIfr4pYanULL+MdXEvBHoz27QIr ASWWzKRP+r1wLi8W6l5YmQD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fCh0Ysai BgG/zIhv/79xZjs1QJF9ipfozhgzcs9rN0a/IEuRs9geK11Au+lrzrw4GKzE6/+2t2IXD1vD4 TAz54nwGT62SkQJ+PUIzRXaxoHI= X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, 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 Am 26.04.23 um 15:16 schrieb James Seo: > On Mon, Apr 24, 2023 at 11:13:36PM +0200, Armin Wolf wrote: >> Am 24.04.23 um 12:05 schrieb James Seo: >> >>> + for (i = 0; i < HP_WMI_MAX_INSTANCES; i++, pevents++) { >> Hi, >> >> the WMI driver core already knows how many instances of a given WMI object are available. >> Unfortunately, this information is currently unavailable to drivers. Would it be convenient >> for you to access this information? I could try to implement such a function if needed. >> >>> + for (i = 0; i < HP_WMI_MAX_INSTANCES; i++, info++) { >> Same as above. >> > Hello, > > Having the WMI object instance count wouldn't make much difference to > me for now. The driver has to iterate through all instances during > init anyway. If I were forced to accommodate 50+ sensors, I'd rewrite > some things and I think I'd want such a function then, but I picked > the current arbitrary limit of 32 because even that seems unlikely. > > So, maybe don't worry about it unless you want to. Or am I missing > something? > Hi, i already have a experimental patch available which adds such a function. If you could test this patch to see if it works, then i could submit it upstream where other drivers could profit from being able to know the number of WMI object instances. Your driver could also profit from such a function, as it could optimize the amount of memory allocated to store WMI object data. The current instance discovery algorithm (using a for-loop and break on error) also has a potential issue: when a single WMI call fails for some reason (ACPI error, ...), all following WMI instances are being ignored. I will post a RFC patch implementing such a function and CC you and a couple of people who might be interested. If you want to test this function, then you can use this patch. If you find out that the function does not work for you, then you can just continue with your current approach. Armin Wolf >>> + err = wmi_install_notify_handler(HP_WMI_EVENT_GUID, >>> + hp_wmi_notify, state); >> As a side note: the GUID-based interface for accessing WMI devices is deprecated. >> It has known problems handling WMI devices sharing GUIDs and/or notification IDs. However, >> the modern bus-based WMI interface (currently) does not support such aggregate devices well, >> so i think using wmi_install_notify_handler() is still the best thing you can currently do. >> > Interesting. Of course I had no idea. Though, for some strange > reason, it does look like some documentation to that effect has > emerged on the topic since the last time I checked ;) > >>> + if (err) { >>> + dev_info(dev, "Failed to subscribe to WMI event\n"); >>> + return false; >>> + } >>> + >>> + err = devm_add_action(dev, hp_wmi_devm_notify_remove, NULL); >>> + if (err) { >>> + wmi_remove_notify_handler(HP_WMI_EVENT_GUID); >>> + return false; >>> + } >> Maybe use devm_add_action_or_reset() here? > Will do. > > Thanks for reviewing/writing. > > James