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

Configure Feed

Select the types of activity you want to include in your feed.

platform/x86: Rename lenovo-wmi-capdata01 to lenovo-wmi-capdata

Prepare for the upcoming changes to make it suitable to retrieve
and provide other Capability Data as well.

Signed-off-by: Rong Zhang <i@rong.moe>
Reviewed-by: Derek J. Clark <derekjohn.clark@gmail.com>
Tested-by: Derek J. Clark <derekjohn.clark@gmail.com>
Link: https://patch.msgid.link/20260120182104.163424-3-i@rong.moe
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

authored by

Rong Zhang and committed by
Ilpo Järvinen
f28d76b1 465dc9da

+78 -73
+2 -2
drivers/platform/x86/lenovo/Kconfig
··· 233 233 To compile this driver as a module, choose M here: the module will 234 234 be called lenovo-yogabook. 235 235 236 - config LENOVO_WMI_DATA01 236 + config LENOVO_WMI_CAPDATA 237 237 tristate 238 238 depends on ACPI_WMI 239 239 ··· 264 264 tristate "Lenovo Other Mode WMI Driver" 265 265 depends on ACPI_WMI 266 266 select FW_ATTR_CLASS 267 - select LENOVO_WMI_DATA01 267 + select LENOVO_WMI_CAPDATA 268 268 select LENOVO_WMI_EVENTS 269 269 select LENOVO_WMI_HELPERS 270 270 help
+1 -1
drivers/platform/x86/lenovo/Makefile
··· 12 12 lenovo-target-$(CONFIG_YOGABOOK) += yogabook.o 13 13 lenovo-target-$(CONFIG_YT2_1380) += yoga-tab2-pro-1380-fastcharger.o 14 14 lenovo-target-$(CONFIG_LENOVO_WMI_CAMERA) += wmi-camera.o 15 - lenovo-target-$(CONFIG_LENOVO_WMI_DATA01) += wmi-capdata01.o 15 + lenovo-target-$(CONFIG_LENOVO_WMI_CAPDATA) += wmi-capdata.o 16 16 lenovo-target-$(CONFIG_LENOVO_WMI_EVENTS) += wmi-events.o 17 17 lenovo-target-$(CONFIG_LENOVO_WMI_HELPERS) += wmi-helpers.o 18 18 lenovo-target-$(CONFIG_LENOVO_WMI_GAMEZONE) += wmi-gamezone.o
+63 -61
drivers/platform/x86/lenovo/wmi-capdata01.c drivers/platform/x86/lenovo/wmi-capdata.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-or-later 2 2 /* 3 - * Lenovo Capability Data 01 WMI Data Block driver. 3 + * Lenovo Capability Data WMI Data Block driver. 4 4 * 5 - * Lenovo Capability Data 01 provides information on tunable attributes used by 6 - * the "Other Mode" WMI interface. The data includes if the attribute is 7 - * supported by the hardware, the default_value, max_value, min_value, and step 8 - * increment. Each attribute has multiple pages, one for each of the thermal 9 - * modes managed by the Gamezone interface. 5 + * Lenovo Capability Data provides information on tunable attributes used by 6 + * the "Other Mode" WMI interface. 7 + * 8 + * Capability Data 01 includes if the attribute is supported by the hardware, 9 + * and the default_value, max_value, min_value, and step increment. Each 10 + * attribute has multiple pages, one for each of the thermal modes managed by 11 + * the Gamezone interface. 10 12 * 11 13 * Copyright (C) 2025 Derek J. Clark <derekjohn.clark@gmail.com> 14 + * - Initial implementation (formerly named lenovo-wmi-capdata01) 12 15 */ 13 16 14 17 #include <linux/acpi.h> ··· 29 26 #include <linux/types.h> 30 27 #include <linux/wmi.h> 31 28 32 - #include "wmi-capdata01.h" 29 + #include "wmi-capdata.h" 33 30 34 31 #define LENOVO_CAPABILITY_DATA_01_GUID "7A8F5407-CB67-4D6E-B547-39B3BE018154" 35 32 36 33 #define ACPI_AC_CLASS "ac_adapter" 37 34 #define ACPI_AC_NOTIFY_STATUS 0x80 38 35 39 - struct lwmi_cd01_priv { 36 + struct lwmi_cd_priv { 40 37 struct notifier_block acpi_nb; /* ACPI events */ 41 38 struct wmi_device *wdev; 42 - struct cd01_list *list; 39 + struct cd_list *list; 43 40 }; 44 41 45 - struct cd01_list { 42 + struct cd_list { 46 43 struct mutex list_mutex; /* list R/W mutex */ 47 44 u8 count; 48 45 struct capdata01 data[]; 49 46 }; 50 47 51 48 /** 52 - * lwmi_cd01_component_bind() - Bind component to master device. 53 - * @cd01_dev: Pointer to the lenovo-wmi-capdata01 driver parent device. 49 + * lwmi_cd_component_bind() - Bind component to master device. 50 + * @cd_dev: Pointer to the lenovo-wmi-capdata driver parent device. 54 51 * @om_dev: Pointer to the lenovo-wmi-other driver parent device. 55 - * @data: capdata01_list object pointer used to return the capability data. 52 + * @data: cd_list object pointer used to return the capability data. 56 53 * 57 - * On lenovo-wmi-other's master bind, provide a pointer to the local capdata01 58 - * list. This is used to call lwmi_cd01_get_data to look up attribute data 54 + * On lenovo-wmi-other's master bind, provide a pointer to the local capdata 55 + * list. This is used to call lwmi_cd*_get_data to look up attribute data 59 56 * from the lenovo-wmi-other driver. 60 57 * 61 58 * Return: 0 62 59 */ 63 - static int lwmi_cd01_component_bind(struct device *cd01_dev, 64 - struct device *om_dev, void *data) 60 + static int lwmi_cd_component_bind(struct device *cd_dev, 61 + struct device *om_dev, void *data) 65 62 { 66 - struct lwmi_cd01_priv *priv = dev_get_drvdata(cd01_dev); 67 - struct cd01_list **cd01_list = data; 63 + struct lwmi_cd_priv *priv = dev_get_drvdata(cd_dev); 64 + struct cd_list **cd_list = data; 68 65 69 - *cd01_list = priv->list; 66 + *cd_list = priv->list; 70 67 71 68 return 0; 72 69 } 73 70 74 - static const struct component_ops lwmi_cd01_component_ops = { 75 - .bind = lwmi_cd01_component_bind, 71 + static const struct component_ops lwmi_cd_component_ops = { 72 + .bind = lwmi_cd_component_bind, 76 73 }; 77 74 78 75 /** 79 76 * lwmi_cd01_get_data - Get the data of the specified attribute 80 - * @list: The lenovo-wmi-capdata01 pointer to its cd01_list struct. 77 + * @list: The lenovo-wmi-capdata pointer to its cd_list struct. 81 78 * @attribute_id: The capdata attribute ID to be found. 82 79 * @output: Pointer to a capdata01 struct to return the data. 83 80 * ··· 86 83 * 87 84 * Return: 0 on success, or -EINVAL. 88 85 */ 89 - int lwmi_cd01_get_data(struct cd01_list *list, u32 attribute_id, struct capdata01 *output) 86 + int lwmi_cd01_get_data(struct cd_list *list, u32 attribute_id, struct capdata01 *output) 90 87 { 91 88 u8 idx; 92 89 ··· 100 97 101 98 return -EINVAL; 102 99 } 103 - EXPORT_SYMBOL_NS_GPL(lwmi_cd01_get_data, "LENOVO_WMI_CD01"); 100 + EXPORT_SYMBOL_NS_GPL(lwmi_cd01_get_data, "LENOVO_WMI_CAPDATA"); 104 101 105 102 /** 106 - * lwmi_cd01_cache() - Cache all WMI data block information 107 - * @priv: lenovo-wmi-capdata01 driver data. 103 + * lwmi_cd_cache() - Cache all WMI data block information 104 + * @priv: lenovo-wmi-capdata driver data. 108 105 * 109 106 * Loop through each WMI data block and cache the data. 110 107 * 111 108 * Return: 0 on success, or an error. 112 109 */ 113 - static int lwmi_cd01_cache(struct lwmi_cd01_priv *priv) 110 + static int lwmi_cd_cache(struct lwmi_cd_priv *priv) 114 111 { 115 112 int idx; 116 113 ··· 134 131 } 135 132 136 133 /** 137 - * lwmi_cd01_alloc() - Allocate a cd01_list struct in drvdata 138 - * @priv: lenovo-wmi-capdata01 driver data. 134 + * lwmi_cd_alloc() - Allocate a cd_list struct in drvdata 135 + * @priv: lenovo-wmi-capdata driver data. 139 136 * 140 - * Allocate a cd01_list struct large enough to contain data from all WMI data 137 + * Allocate a cd_list struct large enough to contain data from all WMI data 141 138 * blocks provided by the interface. 142 139 * 143 140 * Return: 0 on success, or an error. 144 141 */ 145 - static int lwmi_cd01_alloc(struct lwmi_cd01_priv *priv) 142 + static int lwmi_cd_alloc(struct lwmi_cd_priv *priv) 146 143 { 147 - struct cd01_list *list; 144 + struct cd_list *list; 148 145 size_t list_size; 149 146 int count, ret; 150 147 ··· 166 163 } 167 164 168 165 /** 169 - * lwmi_cd01_setup() - Cache all WMI data block information 170 - * @priv: lenovo-wmi-capdata01 driver data. 166 + * lwmi_cd_setup() - Cache all WMI data block information 167 + * @priv: lenovo-wmi-capdata driver data. 171 168 * 172 - * Allocate a cd01_list struct large enough to contain data from all WMI data 169 + * Allocate a cd_list struct large enough to contain data from all WMI data 173 170 * blocks provided by the interface. Then loop through each data block and 174 171 * cache the data. 175 172 * 176 173 * Return: 0 on success, or an error code. 177 174 */ 178 - static int lwmi_cd01_setup(struct lwmi_cd01_priv *priv) 175 + static int lwmi_cd_setup(struct lwmi_cd_priv *priv) 179 176 { 180 177 int ret; 181 178 182 - ret = lwmi_cd01_alloc(priv); 179 + ret = lwmi_cd_alloc(priv); 183 180 if (ret) 184 181 return ret; 185 182 186 - return lwmi_cd01_cache(priv); 183 + return lwmi_cd_cache(priv); 187 184 } 188 185 189 186 /** 190 - * lwmi_cd01_notifier_call() - Call method for lenovo-wmi-capdata01 driver notifier. 187 + * lwmi_cd01_notifier_call() - Call method for cd01 notifier. 191 188 * block call chain. 192 189 * @nb: The notifier_block registered to lenovo-wmi-events driver. 193 190 * @action: Unused. ··· 202 199 void *data) 203 200 { 204 201 struct acpi_bus_event *event = data; 205 - struct lwmi_cd01_priv *priv; 202 + struct lwmi_cd_priv *priv; 206 203 int ret; 207 204 208 205 if (strcmp(event->device_class, ACPI_AC_CLASS) != 0) 209 206 return NOTIFY_DONE; 210 207 211 - priv = container_of(nb, struct lwmi_cd01_priv, acpi_nb); 208 + priv = container_of(nb, struct lwmi_cd_priv, acpi_nb); 212 209 213 210 switch (event->type) { 214 211 case ACPI_AC_NOTIFY_STATUS: 215 - ret = lwmi_cd01_cache(priv); 212 + ret = lwmi_cd_cache(priv); 216 213 if (ret) 217 214 return NOTIFY_BAD; 218 215 ··· 233 230 unregister_acpi_notifier(acpi_nb); 234 231 } 235 232 236 - static int lwmi_cd01_probe(struct wmi_device *wdev, const void *context) 237 - 233 + static int lwmi_cd_probe(struct wmi_device *wdev, const void *context) 238 234 { 239 - struct lwmi_cd01_priv *priv; 235 + struct lwmi_cd_priv *priv; 240 236 int ret; 241 237 242 238 priv = devm_kzalloc(&wdev->dev, sizeof(*priv), GFP_KERNEL); ··· 245 243 priv->wdev = wdev; 246 244 dev_set_drvdata(&wdev->dev, priv); 247 245 248 - ret = lwmi_cd01_setup(priv); 246 + ret = lwmi_cd_setup(priv); 249 247 if (ret) 250 248 return ret; 251 249 ··· 259 257 if (ret) 260 258 return ret; 261 259 262 - return component_add(&wdev->dev, &lwmi_cd01_component_ops); 260 + return component_add(&wdev->dev, &lwmi_cd_component_ops); 263 261 } 264 262 265 - static void lwmi_cd01_remove(struct wmi_device *wdev) 263 + static void lwmi_cd_remove(struct wmi_device *wdev) 266 264 { 267 - component_del(&wdev->dev, &lwmi_cd01_component_ops); 265 + component_del(&wdev->dev, &lwmi_cd_component_ops); 268 266 } 269 267 270 - static const struct wmi_device_id lwmi_cd01_id_table[] = { 268 + static const struct wmi_device_id lwmi_cd_id_table[] = { 271 269 { LENOVO_CAPABILITY_DATA_01_GUID, NULL }, 272 270 {} 273 271 }; 274 272 275 - static struct wmi_driver lwmi_cd01_driver = { 273 + static struct wmi_driver lwmi_cd_driver = { 276 274 .driver = { 277 - .name = "lenovo_wmi_cd01", 275 + .name = "lenovo_wmi_capdata", 278 276 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 279 277 }, 280 - .id_table = lwmi_cd01_id_table, 281 - .probe = lwmi_cd01_probe, 282 - .remove = lwmi_cd01_remove, 278 + .id_table = lwmi_cd_id_table, 279 + .probe = lwmi_cd_probe, 280 + .remove = lwmi_cd_remove, 283 281 .no_singleton = true, 284 282 }; 285 283 ··· 292 290 */ 293 291 int lwmi_cd01_match(struct device *dev, void *data) 294 292 { 295 - return dev->driver == &lwmi_cd01_driver.driver; 293 + return dev->driver == &lwmi_cd_driver.driver; 296 294 } 297 - EXPORT_SYMBOL_NS_GPL(lwmi_cd01_match, "LENOVO_WMI_CD01"); 295 + EXPORT_SYMBOL_NS_GPL(lwmi_cd01_match, "LENOVO_WMI_CAPDATA"); 298 296 299 - module_wmi_driver(lwmi_cd01_driver); 297 + module_wmi_driver(lwmi_cd_driver); 300 298 301 - MODULE_DEVICE_TABLE(wmi, lwmi_cd01_id_table); 299 + MODULE_DEVICE_TABLE(wmi, lwmi_cd_id_table); 302 300 MODULE_AUTHOR("Derek J. Clark <derekjohn.clark@gmail.com>"); 303 - MODULE_DESCRIPTION("Lenovo Capability Data 01 WMI Driver"); 301 + MODULE_DESCRIPTION("Lenovo Capability Data WMI Driver"); 304 302 MODULE_LICENSE("GPL");
+5 -5
drivers/platform/x86/lenovo/wmi-capdata01.h drivers/platform/x86/lenovo/wmi-capdata.h
··· 2 2 3 3 /* Copyright (C) 2025 Derek J. Clark <derekjohn.clark@gmail.com> */ 4 4 5 - #ifndef _LENOVO_WMI_CAPDATA01_H_ 6 - #define _LENOVO_WMI_CAPDATA01_H_ 5 + #ifndef _LENOVO_WMI_CAPDATA_H_ 6 + #define _LENOVO_WMI_CAPDATA_H_ 7 7 8 8 #include <linux/types.h> 9 9 10 10 struct device; 11 - struct cd01_list; 11 + struct cd_list; 12 12 13 13 struct capdata01 { 14 14 u32 id; ··· 19 19 u32 max_value; 20 20 }; 21 21 22 - int lwmi_cd01_get_data(struct cd01_list *list, u32 attribute_id, struct capdata01 *output); 22 + int lwmi_cd01_get_data(struct cd_list *list, u32 attribute_id, struct capdata01 *output); 23 23 int lwmi_cd01_match(struct device *dev, void *data); 24 24 25 - #endif /* !_LENOVO_WMI_CAPDATA01_H_ */ 25 + #endif /* !_LENOVO_WMI_CAPDATA_H_ */
+7 -4
drivers/platform/x86/lenovo/wmi-other.c
··· 34 34 #include <linux/types.h> 35 35 #include <linux/wmi.h> 36 36 37 - #include "wmi-capdata01.h" 37 + #include "wmi-capdata.h" 38 38 #include "wmi-events.h" 39 39 #include "wmi-gamezone.h" 40 40 #include "wmi-helpers.h" ··· 74 74 75 75 struct lwmi_om_priv { 76 76 struct component_master_ops *ops; 77 - struct cd01_list *cd01_list; /* only valid after capdata01 bind */ 77 + 78 + /* only valid after capdata bind */ 79 + struct cd_list *cd01_list; 80 + 78 81 struct device *fw_attr_dev; 79 82 struct kset *fw_attr_kset; 80 83 struct notifier_block nb; ··· 579 576 static int lwmi_om_master_bind(struct device *dev) 580 577 { 581 578 struct lwmi_om_priv *priv = dev_get_drvdata(dev); 582 - struct cd01_list *tmp_list; 579 + struct cd_list *tmp_list; 583 580 int ret; 584 581 585 582 ret = component_bind_all(dev, &tmp_list); ··· 660 657 661 658 module_wmi_driver(lwmi_other_driver); 662 659 663 - MODULE_IMPORT_NS("LENOVO_WMI_CD01"); 660 + MODULE_IMPORT_NS("LENOVO_WMI_CAPDATA"); 664 661 MODULE_IMPORT_NS("LENOVO_WMI_HELPERS"); 665 662 MODULE_DEVICE_TABLE(wmi, lwmi_other_id_table); 666 663 MODULE_AUTHOR("Derek J. Clark <derekjohn.clark@gmail.com>");