From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-176.mta1.migadu.com (out-176.mta1.migadu.com [95.215.58.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B6A9519CC0E for ; Wed, 26 Mar 2025 19:46:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743018386; cv=none; b=YIsGPDO/K5clNC3e9h4xc3MXDrvJ+D31B4E/2VNruLYRs5ZNxfWxdGiOEQ+QjwqobiKUj+LicBRxcNxpVN4qPbkvKC6zimEbKgrmup9eYyoQpAeYrAC0YBeN7woPS4u40MvPlCvvXa/10xQKGm5RYlMmvFME8RRfpNTfxQV65xo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743018386; c=relaxed/simple; bh=7o5ipESF1n74USomiVTP0aSI5G1knR2d4jmiY+WIn9c=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=RZkaKpn3Sqs37SR2d2vWV4CIiTEkJpSMK09qyzkIaC1wPyag9yCPIdpapxmD+jXJGIRFu3y/2wyCMa2rmcsMEAiZA5nKccA3OpBxh5gHQqm3EB/jTE58tATdaXmPIh/DY9yw8RIBRH6bMujcpBRR2u6cQcJRFUnACt3w/XbqMxQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=MbZk9cC8; arc=none smtp.client-ip=95.215.58.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="MbZk9cC8" Message-ID: <3228bdd0-545f-49cd-849b-a38c2988374e@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1743018381; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e0Oq97sZ3K5gk2m6m6FyxWbcbb/mq5WF9fJ4MjK9gvM=; b=MbZk9cC8H295eiqXUarCZJ6Q4OfZc82VQTGDnbXhFb0dZuIr5nLegqvmJiTLhmrNVIYP+m ZDX6cmz/E8+nrh/atTKMJ4n1G1EJjEW5a3Aa1msLEmBIEN446tkRn6kaN29LwqOhluFrTE gu4y90D2BaWN2YFzEcP7WNDtax9th0I= Date: Wed, 26 Mar 2025 12:45:45 -0700 Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH v4 2/6 RESEND] platform/x86: Add lenovo-wmi-helpers To: "Derek J. Clark" , Hans de Goede , =?UTF-8?Q?Ilpo_J=C3=A4rvinen?= Cc: Armin Wolf , Jonathan Corbet , Mario Limonciello , Luke Jones , Xino Ni , Zhixin Zhang , Mia Shao , Mark Pearson , "Pierre-Loup A . Griffais" , "Cody T . -H . Chiu" , John Martens , platform-driver-x86@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org References: <20250317144326.5850-1-derekjohn.clark@gmail.com> <20250317144326.5850-3-derekjohn.clark@gmail.com> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Matthew Schwartz In-Reply-To: <20250317144326.5850-3-derekjohn.clark@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 3/17/25 7:43 AM, Derek J. Clark wrote: > Adds documentation for all new lenovo-wmi drivers. > > Signed-off-by: Derek J. Clark The helpers are working with the other drivers on my Legion Go and Legion Go S. I left one minor comment for a typo in-line. Tested-by: Matthew Schwartz > --- > v4: > - Changed namespace to LENOVO_WMI_HELPERS from LENOVO_WMI. > - Changed filenames to lenovo-wmi-helpers from lenovo-wmi. > - Removed structs and functions implemented by other drivers. > --- > MAINTAINERS | 2 + > drivers/platform/x86/Kconfig | 4 ++ > drivers/platform/x86/Makefile | 1 + > drivers/platform/x86/lenovo-wmi-helpers.c | 64 +++++++++++++++++++++++ > drivers/platform/x86/lenovo-wmi-helpers.h | 24 +++++++++ > 5 files changed, 95 insertions(+) > create mode 100644 drivers/platform/x86/lenovo-wmi-helpers.c > create mode 100644 drivers/platform/x86/lenovo-wmi-helpers.h > > diff --git a/MAINTAINERS b/MAINTAINERS > index 675f4b26426d..3a370a18b806 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -13164,6 +13164,8 @@ L: platform-driver-x86@vger.kernel.org > S: Maintained > F: Documentation/wmi/devices/lenovo-wmi-gamezone.rst > F: Documentation/wmi/devices/lenovo-wmi-other.rst > +F: drivers/platform/x86/lenovo-wmi-helpers.c > +F: drivers/platform/x86/lenovo-wmi-helpers.h > > LENOVO WMI HOTKEY UTILITIES DRIVER > M: Jackie Dong > diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig > index 43407e76476b..bece1ba61417 100644 > --- a/drivers/platform/x86/Kconfig > +++ b/drivers/platform/x86/Kconfig > @@ -459,6 +459,10 @@ config IBM_RTL > state = 0 (BIOS SMIs on) > state = 1 (BIOS SMIs off) > > +config LENOVO_WMI_HELPERS > + tristate > + depends on ACPI_WMI > + > config IDEAPAD_LAPTOP > tristate "Lenovo IdeaPad Laptop Extras" > depends on ACPI > diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile > index 650dfbebb6c8..5a9f4e94f78b 100644 > --- a/drivers/platform/x86/Makefile > +++ b/drivers/platform/x86/Makefile > @@ -69,6 +69,7 @@ obj-$(CONFIG_THINKPAD_LMI) += think-lmi.o > obj-$(CONFIG_YOGABOOK) += lenovo-yogabook.o > obj-$(CONFIG_YT2_1380) += lenovo-yoga-tab2-pro-1380-fastcharger.o > obj-$(CONFIG_LENOVO_WMI_CAMERA) += lenovo-wmi-camera.o > +obj-$(CONFIG_LENOVO_WMI_HELPERS) += lenovo-wmi-helpers.o > > # Intel > obj-y += intel/ > diff --git a/drivers/platform/x86/lenovo-wmi-helpers.c b/drivers/platform/x86/lenovo-wmi-helpers.c > new file mode 100644 > index 000000000000..36d553502223 > --- /dev/null > +++ b/drivers/platform/x86/lenovo-wmi-helpers.c > @@ -0,0 +1,64 @@ > +// SPDX-License-Identifier: GPL-2.0-or-later > +/* > + * Lenovo Legion WMI helpers driver. The Lenovo Legion WMI interface is > + * broken up into multiple GUID interfaces that require cross-references > + * between GUID's for some functionality. The "Custom Method" interface is a > + * legacy interface for managing and displaying CPU & GPU power and hwmon > + * settings and readings. The "Other Mode" interface is a modern interface > + * that replaces or extends the "Custom Method" interface methods. The > + * "Gamezone" interface adds advanced features such as fan profiles and > + * overclocking. The "Lighting" interface adds control of various status > + * lights related to different hardware components. Each of these drivers > + * uses a common procedure to get data fro the WMI interface, enumerated here. "fro" should be "from" right? > + * > + * Copyright(C) 2025 Derek J. Clark > + * > + */ > + > +#include > +#include "lenovo-wmi-helpers.h" > + > +/* > + * lwmi_dev_evaluate_method() - Helper function to call wmidev_evaluate_method > + * for Lenovo WMI device method calls that return an ACPI integer. > + * @wdev: Pointer to the WMI device to be called. > + * @instance: Instance of the called method. > + * @method_id: WMI Method ID for the method to be called. > + * @buf: Buffer of all arguments for the given method_id. > + * @size: Length of the buffer. > + * @retval: Pointer for the return value to be assigned. > + * > + * Returns: 0, or an error. > + */ > +int lwmi_dev_evaluate_method(struct wmi_device *wdev, u8 instance, > + u32 method_id, unsigned char *buf, size_t size, > + u32 *retval) > +{ > + struct acpi_buffer input = { size, buf }; > + struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; > + union acpi_object *ret_obj __free(kfree) = NULL; > + acpi_status status; > + > + status = wmidev_evaluate_method(wdev, instance, method_id, &input, > + &output); > + > + if (ACPI_FAILURE(status)) > + return -EIO; > + > + if (retval) { > + ret_obj = output.pointer; > + if (!ret_obj) > + return -ENODATA; > + > + if (ret_obj->type != ACPI_TYPE_INTEGER) > + return -ENXIO; > + > + *retval = (u32)ret_obj->integer.value; > + } > + return 0; > +}; > +EXPORT_SYMBOL_NS_GPL(lwmi_dev_evaluate_method, "LENOVO_WMI_HELPERS"); > + > +MODULE_AUTHOR("Derek J. Clark "); > +MODULE_DESCRIPTION("Lenovo WMI Helpers Driver"); > +MODULE_LICENSE("GPL"); > diff --git a/drivers/platform/x86/lenovo-wmi-helpers.h b/drivers/platform/x86/lenovo-wmi-helpers.h > new file mode 100644 > index 000000000000..7e0d7870790e > --- /dev/null > +++ b/drivers/platform/x86/lenovo-wmi-helpers.h > @@ -0,0 +1,24 @@ > +/* SPDX-License-Identifier: GPL-2.0-or-later > + * > + * Copyright(C) 2025 Derek J. Clark > + * > + */ > +#include > +#include > + > +#ifndef _LENOVO_WMI_HELPERS_H_ > +#define _LENOVO_WMI_HELPERS_H_ > + > +#include > +#include > + > +struct wmi_method_args_32 { > + u32 arg0; > + u32 arg1; > +}; > + > +int lwmi_dev_evaluate_method(struct wmi_device *wdev, u8 instance, > + u32 method_id, unsigned char *buf, size_t size, > + u32 *retval); > + > +#endif /* !_LENOVO_WMI_HELPERS_H_ */