mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Armin Wolf <W_Armin@gmx.de>, 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: Re: [RFC v2 1/2] platform/x86: wmi: Allow retrieving the number of WMI object instances
Date: Sat, 29 Apr 2023 11:27:24 +0200	[thread overview]
Message-ID: <b6340042-e0fa-5706-0b9b-1d9dd17da11a@redhat.com> (raw)
In-Reply-To: <4db0e619-7f18-3f6b-9fb3-769f95233a72@gmx.de>

Hi,

On 4/27/23 18:26, Armin Wolf wrote:
> Am 27.04.23 um 11:43 schrieb Hans de Goede:
> 
>> Hi Armin,
>>
>> Thank you for your work on this.
>>
>> On 4/26/23 23:28, Armin Wolf wrote:
>>> Currently, the WMI driver core knows how many instances of a given
>>> WMI object exist, but WMI drivers cannot access this information.
>>> At the same time, some current and upcoming WMI drivers want to
>>> have access to this information. Add wmi_instance_count() and
>>> wmidev_instance_count() to allow WMI drivers to get the number of
>>> WMI object instances.
>>>
>>> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
>>> ---
>>>   drivers/platform/x86/wmi.c | 40 ++++++++++++++++++++++++++++++++++++++
>>>   include/linux/acpi.h       |  2 ++
>>>   include/linux/wmi.h        |  2 ++
>>>   3 files changed, 44 insertions(+)
>>>
>>> diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
>>> index c226dd4163a1..7c1a904dec5f 100644
>>> --- a/drivers/platform/x86/wmi.c
>>> +++ b/drivers/platform/x86/wmi.c
>>> @@ -263,6 +263,46 @@ int set_required_buffer_size(struct wmi_device *wdev, u64 length)
>>>   }
>>>   EXPORT_SYMBOL_GPL(set_required_buffer_size);
>>>
>>> +/**
>>> + * wmi_instance_count - Get number of WMI object instances
>>> + * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
>>> + * @instance_count: variable to hold the instance count
>>> + *
>>> + * Get the number of WMI object instances.
>>> + *
>>> + * Returns: acpi_status signaling success or error.
>>> + */
>>> +acpi_status wmi_instance_count(const char *guid_string, u8 *instance_count)
>>> +{
>>> +    struct wmi_block *wblock;
>>> +    acpi_status status;
>>> +
>>> +    status = find_guid(guid_string, &wblock);
>>> +    if (ACPI_FAILURE(status))
>>> +        return status;
>>> +
>>> +    *instance_count = wmidev_instance_count(&wblock->dev);
>>> +
>>> +    return AE_OK;
>>> +}
>>> +EXPORT_SYMBOL_GPL(wmi_instance_count);
>> I would prefer this to have a normal kernel function prototype
>> which returns -errno rather then returning an acpi_status. E.g. :
>>
>> /**
>>   * wmi_instance_count - Get number of WMI object instances
>>   * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
>>   *
>>   * Get the number of WMI object instances.
>>   *
>>   * Returns: The number of WMI object instances, 0 if the GUID is not found.
>>   */
>> int wmi_instance_count(const char *guid_string)
>> {
>>     struct wmi_block *wblock;
>>     acpi_status status;
>>
>>     status = find_guid(guid_string, &wblock);
>>     if (ACPI_FAILURE(status))
>>         return 0;
>>
>>     return wmidev_instance_count(&wblock->dev);
>> }
>> EXPORT_SYMBOL_GPL(wmi_instance_count);
>>
>> This will also allow this to completely replace
>> the get_instance_count() function in dell-wmi-sysman.
>>
>> Note I have just gone with always returning 0 here
>> on error. I guess you could look at the status and
>> return 0 for not-found and -errno for other errors
>> but I don't think any callers will care for the difference,
>> so just always returning 0 seems easier for callers to
>> deal with.
>>
>> As always this is just a suggestion, let me know if
>> you think this is a bad idea.
>>
>> Regards,
>>
>> Hans
>>
> I like this idea. Returning a negative errno on error would allow drivers to
> distinguish between "WMI object not found" and "zero instances found", which
> might be useful for some drivers.
> 
> Maybe a function for converting ACPI errors to POSIX errors already exists,
> otherwise i will just write one myself.

Ok, that sounds good to me. I'm looking forward to a non RFC submission
of these changes.

Regards,

Hans



  reply	other threads:[~2023-04-29  9:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-26 21:28 [RFC v2 0/2] platform/x86: " Armin Wolf
2023-04-26 21:28 ` [RFC v2 1/2] platform/x86: wmi: " Armin Wolf
2023-04-27  6:19   ` James Seo
2023-04-27  9:43   ` Hans de Goede
2023-04-27 16:26     ` Armin Wolf
2023-04-29  9:27       ` Hans de Goede [this message]
2023-04-26 21:28 ` [RFC v2 2/2] platform/x86: dell-sysman: Improve instance detection Armin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b6340042-e0fa-5706-0b9b-1d9dd17da11a@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=Dell.Client.Kernel@dell.com \
    --cc=Mario.Limonciello@amd.com \
    --cc=W_Armin@gmx.de \
    --cc=james@equiv.tech \
    --cc=jorgealtxwork@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markgross@kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=prasanth.ksr@dell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®