Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

platform/x86: asus-wmi: export symbols used for read/write WMI

Export symbols for reading/writing WMI symbols using a namespace.
Existing functions:
- asus_wmi_evaluate_method
- asus_wmi_set_devstate
New function:
- asus_wmi_get_devstate_dsts

The new function is intended for use with DSTS WMI method only and
avoids requiring the asus_wmi driver data to select the WMI method.

Co-developed-by: Denis Benato <denis.benato@linux.dev>
Signed-off-by: Denis Benato <denis.benato@linux.dev>
Signed-off-by: Luke D. Jones <luke@ljones.dev>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Link: https://patch.msgid.link/20251102215319.3126879-2-denis.benato@linux.dev
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

authored by

Luke D. Jones and committed by
Ilpo Järvinen
22ea7b9d ff49362e

+48 -3
+43 -3
drivers/platform/x86/asus-wmi.c
··· 390 390 { 391 391 return asus_wmi_evaluate_method3(method_id, arg0, arg1, 0, retval); 392 392 } 393 - EXPORT_SYMBOL_GPL(asus_wmi_evaluate_method); 393 + EXPORT_SYMBOL_NS_GPL(asus_wmi_evaluate_method, "ASUS_WMI"); 394 394 395 395 static int asus_wmi_evaluate_method5(u32 method_id, 396 396 u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4, u32 *retval) ··· 554 554 return 0; 555 555 } 556 556 557 - int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, 558 - u32 *retval) 557 + /** 558 + * asus_wmi_get_devstate_dsts() - Get the WMI function state. 559 + * @dev_id: The WMI method ID to call. 560 + * @retval: A pointer to where to store the value returned from WMI. 561 + * 562 + * Returns: 563 + * * %-ENODEV - method ID is unsupported. 564 + * * %0 - successful and retval is filled. 565 + * * %other - error from WMI call. 566 + */ 567 + int asus_wmi_get_devstate_dsts(u32 dev_id, u32 *retval) 568 + { 569 + int err; 570 + 571 + err = asus_wmi_evaluate_method(ASUS_WMI_METHODID_DSTS, dev_id, 0, retval); 572 + if (err) 573 + return err; 574 + 575 + if ((*retval & ASUS_WMI_DSTS_PRESENCE_BIT) == 0x00) 576 + return -ENODEV; 577 + 578 + return 0; 579 + } 580 + EXPORT_SYMBOL_NS_GPL(asus_wmi_get_devstate_dsts, "ASUS_WMI"); 581 + 582 + /** 583 + * asus_wmi_set_devstate() - Set the WMI function state. 584 + * 585 + * Note: an asus_wmi_set_devstate() call must be paired with a 586 + * asus_wmi_get_devstate_dsts() to check if the WMI function is supported. 587 + * 588 + * @dev_id: The WMI function to call. 589 + * @ctrl_param: The argument to be used for this WMI function. 590 + * @retval: A pointer to where to store the value returned from WMI. 591 + * 592 + * Returns: 593 + * * %-ENODEV - method ID is unsupported. 594 + * * %0 - successful and retval is filled. 595 + * * %other - error from WMI call. 596 + */ 597 + int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, u32 *retval) 559 598 { 560 599 return asus_wmi_evaluate_method(ASUS_WMI_METHODID_DEVS, dev_id, 561 600 ctrl_param, retval); 562 601 } 602 + EXPORT_SYMBOL_NS_GPL(asus_wmi_set_devstate, "ASUS_WMI"); 563 603 564 604 /* Helper for special devices with magic return codes */ 565 605 static int asus_wmi_get_devstate_bits(struct asus_wmi *asus,
+5
include/linux/platform_data/x86/asus-wmi.h
··· 166 166 #if IS_REACHABLE(CONFIG_ASUS_WMI) 167 167 void set_ally_mcu_hack(enum asus_ally_mcu_hack status); 168 168 void set_ally_mcu_powersave(bool enabled); 169 + int asus_wmi_get_devstate_dsts(u32 dev_id, u32 *retval); 169 170 int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, u32 *retval); 170 171 int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1, u32 *retval); 171 172 #else ··· 177 176 { 178 177 } 179 178 static inline int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, u32 *retval) 179 + { 180 + return -ENODEV; 181 + } 182 + static inline int asus_wmi_get_devstate_dsts(u32 dev_id, u32 *retval) 180 183 { 181 184 return -ENODEV; 182 185 }