From: "Luke D. Jones" <luke@ljones.dev>
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.
Signed-off-by: Denis Benato <benato.denis96@gmail.com>
Signed-off-by: Luke D. Jones <luke@ljones.dev>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/platform/x86/asus-wmi.c | 40 ++++++++++++++++++++--
include/linux/platform_data/x86/asus-wmi.h | 9 +++++
2 files changed, 46 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index f7191fdded14..e31e0264a160 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -390,7 +390,7 @@ int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1, u32 *retval)
{
return asus_wmi_evaluate_method3(method_id, arg0, arg1, 0, retval);
}
-EXPORT_SYMBOL_GPL(asus_wmi_evaluate_method);
+EXPORT_SYMBOL_NS_GPL(asus_wmi_evaluate_method, "ASUS_WMI");
static int asus_wmi_evaluate_method5(u32 method_id,
u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4, u32 *retval)
@@ -554,12 +554,46 @@ static int asus_wmi_get_devstate(struct asus_wmi *asus, u32 dev_id, u32 *retval)
return 0;
}
-int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param,
- u32 *retval)
+/**
+ * asus_wmi_get_devstate_dsts() - Get the WMI function state.
+ * @dev_id: The WMI method ID to call.
+ * @retval: A pointer to where to store the value returned from WMI.
+ * @return: 0 on success and retval is filled.
+ * @return: -ENODEV if the method ID is unsupported.
+ * @return: everything else is an error from WMI call.
+ */
+int asus_wmi_get_devstate_dsts(u32 dev_id, u32 *retval)
+{
+ int err;
+
+ err = asus_wmi_evaluate_method(ASUS_WMI_METHODID_DSTS, dev_id, 0, retval);
+ if (err)
+ return err;
+
+ if (*retval == ASUS_WMI_UNSUPPORTED_METHOD)
+ return -ENODEV;
+
+ return 0;
+}
+EXPORT_SYMBOL_NS_GPL(asus_wmi_get_devstate_dsts, "ASUS_WMI");
+
+/**
+ * asus_wmi_set_devstate() - Set the WMI function state.
+ * @dev_id: The WMI function to call.
+ * @ctrl_param: The argument to be used for this WMI function.
+ * @retval: A pointer to where to store the value returned from WMI.
+ * @return: 0 on success and retval is filled.
+ * @return: everything else is an error from WMI call.
+ *
+ * A asus_wmi_set_devstate() call must be paired with a
+ * asus_wmi_get_devstate_dsts() to check if the WMI function is supported.
+ */
+int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, u32 *retval)
{
return asus_wmi_evaluate_method(ASUS_WMI_METHODID_DEVS, dev_id,
ctrl_param, retval);
}
+EXPORT_SYMBOL_NS_GPL(asus_wmi_set_devstate, "ASUS_WMI");
/* Helper for special devices with magic return codes */
static int asus_wmi_get_devstate_bits(struct asus_wmi *asus,
diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
index 8a515179113d..b6f15b3d0959 100644
--- a/include/linux/platform_data/x86/asus-wmi.h
+++ b/include/linux/platform_data/x86/asus-wmi.h
@@ -166,6 +166,7 @@ enum asus_ally_mcu_hack {
#if IS_REACHABLE(CONFIG_ASUS_WMI)
void set_ally_mcu_hack(enum asus_ally_mcu_hack status);
void set_ally_mcu_powersave(bool enabled);
+int asus_wmi_get_devstate_dsts(u32 dev_id, u32 *retval);
int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, u32 *retval);
int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1, u32 *retval);
#else
@@ -179,6 +180,14 @@ static inline int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, u32 *retval)
{
return -ENODEV;
}
+static inline int asus_wmi_get_devstate_dsts(u32 dev_id, u32 *retval)
+{
+ return -ENODEV;
+}
+static inline int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, u32 *retval)
+{
+ return -ENODEV;
+}
static inline int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1,
u32 *retval)
{
--
2.50.0
Hi Denis, kernel test robot noticed the following build errors: [auto build test ERROR on linus/master] [also build test ERROR on v6.16-rc3 next-20250627] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Denis-Benato/platform-x86-asus-wmi-export-symbols-used-for-read-write-WMI/20250629-211651 base: linus/master patch link: https://lore.kernel.org/r/20250629131423.9013-2-benato.denis96%40gmail.com patch subject: [PATCH v9 1/8] platform/x86: asus-wmi: export symbols used for read/write WMI config: arc-randconfig-002-20250629 (https://download.01.org/0day-ci/archive/20250630/202506300004.OWO7f60c-lkp@intel.com/config) compiler: arc-linux-gcc (GCC) 13.3.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250630/202506300004.OWO7f60c-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202506300004.OWO7f60c-lkp@intel.com/ All errors (new ones prefixed by >>): In file included from drivers/hid/hid-asus.c:29: >> include/linux/platform_data/x86/asus-wmi.h:187:19: error: redefinition of 'asus_wmi_set_devstate' 187 | static inline int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, u32 *retval) | ^~~~~~~~~~~~~~~~~~~~~ include/linux/platform_data/x86/asus-wmi.h:179:19: note: previous definition of 'asus_wmi_set_devstate' with type 'int(u32, u32, u32 *)' {aka 'int(unsigned int, unsigned int, unsigned int *)'} 179 | static inline int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, u32 *retval) | ^~~~~~~~~~~~~~~~~~~~~ vim +/asus_wmi_set_devstate +187 include/linux/platform_data/x86/asus-wmi.h 165 166 #if IS_REACHABLE(CONFIG_ASUS_WMI) 167 void set_ally_mcu_hack(enum asus_ally_mcu_hack status); 168 void set_ally_mcu_powersave(bool enabled); 169 int asus_wmi_get_devstate_dsts(u32 dev_id, u32 *retval); 170 int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, u32 *retval); 171 int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1, u32 *retval); 172 #else 173 static inline void set_ally_mcu_hack(enum asus_ally_mcu_hack status) 174 { 175 } 176 static inline void set_ally_mcu_powersave(bool enabled) 177 { 178 } 179 static inline int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, u32 *retval) 180 { 181 return -ENODEV; 182 } 183 static inline int asus_wmi_get_devstate_dsts(u32 dev_id, u32 *retval) 184 { 185 return -ENODEV; 186 } > 187 static inline int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, u32 *retval) 188 { 189 return -ENODEV; 190 } 191 static inline int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1, 192 u32 *retval) 193 { 194 return -ENODEV; 195 } 196 #endif 197 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
© 2016 - 2025 Red Hat, Inc.