Message ID | 20250317144326.5850-3-derekjohn.clark@gmail.com (mailing list archive) |
---|---|
State | Changes Requested, archived |
Headers | show |
Series | platform/x86: Add Lenovo Gaming Series WMI Drivers | expand |
On 3/17/25 09:43, Derek J. Clark wrote: > Adds documentation for all new lenovo-wmi drivers. You seem to have accidentally lost the commit message for this patch from earlier versions and got the exact same commit message as the first patch. With that fixed the rest of the patch looks fine. You can add for next version. Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> > > Signed-off-by: Derek J. Clark <derekjohn.clark@gmail.com> > --- > 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 <xy-jackie@139.com> > 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. > + * > + * Copyright(C) 2025 Derek J. Clark <derekjohn.clark@gmail.com> > + * > + */ > + > +#include <linux/wmi.h> > +#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 <derekjohn.clark@gmail.com>"); > +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 <derekjohn.clark@gmail.com> > + * > + */ > +#include <linux/notifier.h> > +#include <linux/platform_profile.h> > + > +#ifndef _LENOVO_WMI_HELPERS_H_ > +#define _LENOVO_WMI_HELPERS_H_ > + > +#include <linux/types.h> > +#include <linux/wmi.h> > + > +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_ */
On March 17, 2025 6:27:34 PM HST, Mario Limonciello <superm1@kernel.org> wrote: >On 3/17/25 09:43, Derek J. Clark wrote: >> Adds documentation for all new lenovo-wmi drivers. > >You seem to have accidentally lost the commit message for this patch from earlier versions and got the exact same commit message as the first patch. > >With that fixed the rest of the patch looks fine. You can add for next version. > >Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> > Hmm, not sure how that happened but thanks for letting me know. I'll get that fixed for the next one. - Derek >> >> Signed-off-by: Derek J. Clark <derekjohn.clark@gmail.com> >> --- >> 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 <xy-jackie@139.com> >> 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. >> + * >> + * Copyright(C) 2025 Derek J. Clark <derekjohn.clark@gmail.com> >> + * >> + */ >> + >> +#include <linux/wmi.h> >> +#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 <derekjohn.clark@gmail.com>"); >> +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 <derekjohn.clark@gmail.com> >> + * >> + */ >> +#include <linux/notifier.h> >> +#include <linux/platform_profile.h> >> + >> +#ifndef _LENOVO_WMI_HELPERS_H_ >> +#define _LENOVO_WMI_HELPERS_H_ >> + >> +#include <linux/types.h> >> +#include <linux/wmi.h> >> + >> +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_ */ > - Derek
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 <derekjohn.clark@gmail.com> 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 <matthew.schwartz@linux.dev> > --- > 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 <xy-jackie@139.com> > 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 <derekjohn.clark@gmail.com> > + * > + */ > + > +#include <linux/wmi.h> > +#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 <derekjohn.clark@gmail.com>"); > +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 <derekjohn.clark@gmail.com> > + * > + */ > +#include <linux/notifier.h> > +#include <linux/platform_profile.h> > + > +#ifndef _LENOVO_WMI_HELPERS_H_ > +#define _LENOVO_WMI_HELPERS_H_ > + > +#include <linux/types.h> > +#include <linux/wmi.h> > + > +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_ */
Am 17.03.25 um 15:43 schrieb Derek J. Clark: > Adds documentation for all new lenovo-wmi drivers. > > Signed-off-by: Derek J. Clark <derekjohn.clark@gmail.com> > --- > 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 <xy-jackie@139.com> > 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. > + * > + * Copyright(C) 2025 Derek J. Clark <derekjohn.clark@gmail.com> > + * > + */ > + > +#include <linux/wmi.h> Hi, please also include linux/acpi.h, linux/cleanup.h, linux/errno.h, linux/module.h and linux/export.h. > +#include "lenovo-wmi-helpers.h" > + > +/* Please make sure that the doc comments are valid kernel doc comments, see https://docs.kernel.org/doc-guide/kernel-doc.html for details. For example please make sure that the comments start with a "/**". It would also be nice if you actually describe the purpose of each function. > + * 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 }; Reverse X-mas tree declaration order please. Thanks, Armin Wolf > + 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 <derekjohn.clark@gmail.com>"); > +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 <derekjohn.clark@gmail.com> > + * > + */ > +#include <linux/notifier.h> > +#include <linux/platform_profile.h> > + > +#ifndef _LENOVO_WMI_HELPERS_H_ > +#define _LENOVO_WMI_HELPERS_H_ > + > +#include <linux/types.h> > +#include <linux/wmi.h> > + > +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_ */
On Mon, 17 Mar 2025, Derek J. Clark wrote: > Adds documentation for all new lenovo-wmi drivers. > > Signed-off-by: Derek J. Clark <derekjohn.clark@gmail.com> > --- > 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 <xy-jackie@139.com> > 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. Please add empty comment row here. > 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. > + * > + * Copyright(C) 2025 Derek J. Clark <derekjohn.clark@gmail.com> > + * > + */ > + > +#include <linux/wmi.h> > +#include "lenovo-wmi-helpers.h" Put a space between these lines > + > +/* > + * lwmi_dev_evaluate_method() - Helper function to call wmidev_evaluate_method > + * for Lenovo WMI device method calls that return an ACPI integer. This should be a shorter summary and the rest should be put into own paragraph between the arguments and Return: > + * @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. Return: > + */ > +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 <derekjohn.clark@gmail.com>"); > +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 <derekjohn.clark@gmail.com> > + * Please remove this extra line. > + */ > +#include <linux/notifier.h> > +#include <linux/platform_profile.h> What? Why are these on this side of the ifndef??? And neither is needed by this header AFAICT so please drop them. > +#ifndef _LENOVO_WMI_HELPERS_H_ > +#define _LENOVO_WMI_HELPERS_H_ > + > +#include <linux/types.h> > +#include <linux/wmi.h> This include is not needed (since you're only using it as a pointer). Do a forward declaration instead: struct wmi_device; > + > +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_ */ >
On Wed, Mar 26, 2025 at 5:41 PM Armin Wolf <W_Armin@gmx.de> wrote: > > Am 17.03.25 um 15:43 schrieb Derek J. Clark: > > > Adds documentation for all new lenovo-wmi drivers. > > > > Signed-off-by: Derek J. Clark <derekjohn.clark@gmail.com> > > --- > > 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 <xy-jackie@139.com> > > 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. > > + * > > + * Copyright(C) 2025 Derek J. Clark <derekjohn.clark@gmail.com> > > + * > > + */ > > + > > +#include <linux/wmi.h> > > Hi, > > please also include linux/acpi.h, linux/cleanup.h, linux/errno.h, linux/module.h and linux/export.h. > Acked all include requests for the series. > > +#include "lenovo-wmi-helpers.h" > > + > > +/* > > Please make sure that the doc comments are valid kernel doc comments, see https://docs.kernel.org/doc-guide/kernel-doc.html > for details. For example please make sure that the comments start with a "/**". Will do, thanks > It would also be nice if you actually describe the purpose of each function. I can do that. > > + * 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 }; > > Reverse X-mas tree declaration order please. > Acked Thanks, Derek > Thanks, > Armin Wolf > > > + 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 <derekjohn.clark@gmail.com>"); > > +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 <derekjohn.clark@gmail.com> > > + * > > + */ > > +#include <linux/notifier.h> > > +#include <linux/platform_profile.h> > > + > > +#ifndef _LENOVO_WMI_HELPERS_H_ > > +#define _LENOVO_WMI_HELPERS_H_ > > + > > +#include <linux/types.h> > > +#include <linux/wmi.h> > > + > > +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_ */
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 <xy-jackie@139.com> 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. + * + * Copyright(C) 2025 Derek J. Clark <derekjohn.clark@gmail.com> + * + */ + +#include <linux/wmi.h> +#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 <derekjohn.clark@gmail.com>"); +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 <derekjohn.clark@gmail.com> + * + */ +#include <linux/notifier.h> +#include <linux/platform_profile.h> + +#ifndef _LENOVO_WMI_HELPERS_H_ +#define _LENOVO_WMI_HELPERS_H_ + +#include <linux/types.h> +#include <linux/wmi.h> + +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_ */
Adds documentation for all new lenovo-wmi drivers. Signed-off-by: Derek J. Clark <derekjohn.clark@gmail.com> --- 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