Skip to content

Commit f28d76b

Browse files
Rongronggg9ij-intel
authored andcommitted
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>
1 parent 465dc9d commit f28d76b

5 files changed

Lines changed: 78 additions & 73 deletions

File tree

drivers/platform/x86/lenovo/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ config YT2_1380
233233
To compile this driver as a module, choose M here: the module will
234234
be called lenovo-yogabook.
235235

236-
config LENOVO_WMI_DATA01
236+
config LENOVO_WMI_CAPDATA
237237
tristate
238238
depends on ACPI_WMI
239239

@@ -264,7 +264,7 @@ config LENOVO_WMI_TUNING
264264
tristate "Lenovo Other Mode WMI Driver"
265265
depends on ACPI_WMI
266266
select FW_ATTR_CLASS
267-
select LENOVO_WMI_DATA01
267+
select LENOVO_WMI_CAPDATA
268268
select LENOVO_WMI_EVENTS
269269
select LENOVO_WMI_HELPERS
270270
help

drivers/platform/x86/lenovo/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ lenovo-target-$(CONFIG_LENOVO_YMC) += ymc.o
1212
lenovo-target-$(CONFIG_YOGABOOK) += yogabook.o
1313
lenovo-target-$(CONFIG_YT2_1380) += yoga-tab2-pro-1380-fastcharger.o
1414
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
1616
lenovo-target-$(CONFIG_LENOVO_WMI_EVENTS) += wmi-events.o
1717
lenovo-target-$(CONFIG_LENOVO_WMI_HELPERS) += wmi-helpers.o
1818
lenovo-target-$(CONFIG_LENOVO_WMI_GAMEZONE) += wmi-gamezone.o

drivers/platform/x86/lenovo/wmi-capdata01.c renamed to drivers/platform/x86/lenovo/wmi-capdata.c

Lines changed: 63 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
22
/*
3-
* Lenovo Capability Data 01 WMI Data Block driver.
3+
* Lenovo Capability Data WMI Data Block driver.
44
*
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.
1012
*
1113
* Copyright (C) 2025 Derek J. Clark <derekjohn.clark@gmail.com>
14+
* - Initial implementation (formerly named lenovo-wmi-capdata01)
1215
*/
1316

1417
#include <linux/acpi.h>
@@ -26,55 +29,55 @@
2629
#include <linux/types.h>
2730
#include <linux/wmi.h>
2831

29-
#include "wmi-capdata01.h"
32+
#include "wmi-capdata.h"
3033

3134
#define LENOVO_CAPABILITY_DATA_01_GUID "7A8F5407-CB67-4D6E-B547-39B3BE018154"
3235

3336
#define ACPI_AC_CLASS "ac_adapter"
3437
#define ACPI_AC_NOTIFY_STATUS 0x80
3538

36-
struct lwmi_cd01_priv {
39+
struct lwmi_cd_priv {
3740
struct notifier_block acpi_nb; /* ACPI events */
3841
struct wmi_device *wdev;
39-
struct cd01_list *list;
42+
struct cd_list *list;
4043
};
4144

42-
struct cd01_list {
45+
struct cd_list {
4346
struct mutex list_mutex; /* list R/W mutex */
4447
u8 count;
4548
struct capdata01 data[];
4649
};
4750

4851
/**
49-
* lwmi_cd01_component_bind() - Bind component to master device.
50-
* @cd01_dev: Pointer to the lenovo-wmi-capdata01 driver parent device.
52+
* lwmi_cd_component_bind() - Bind component to master device.
53+
* @cd_dev: Pointer to the lenovo-wmi-capdata driver parent device.
5154
* @om_dev: Pointer to the lenovo-wmi-other driver parent device.
52-
* @data: capdata01_list object pointer used to return the capability data.
55+
* @data: cd_list object pointer used to return the capability data.
5356
*
54-
* On lenovo-wmi-other's master bind, provide a pointer to the local capdata01
55-
* list. This is used to call lwmi_cd01_get_data to look up attribute data
57+
* On lenovo-wmi-other's master bind, provide a pointer to the local capdata
58+
* list. This is used to call lwmi_cd*_get_data to look up attribute data
5659
* from the lenovo-wmi-other driver.
5760
*
5861
* Return: 0
5962
*/
60-
static int lwmi_cd01_component_bind(struct device *cd01_dev,
61-
struct device *om_dev, void *data)
63+
static int lwmi_cd_component_bind(struct device *cd_dev,
64+
struct device *om_dev, void *data)
6265
{
63-
struct lwmi_cd01_priv *priv = dev_get_drvdata(cd01_dev);
64-
struct cd01_list **cd01_list = data;
66+
struct lwmi_cd_priv *priv = dev_get_drvdata(cd_dev);
67+
struct cd_list **cd_list = data;
6568

66-
*cd01_list = priv->list;
69+
*cd_list = priv->list;
6770

6871
return 0;
6972
}
7073

71-
static const struct component_ops lwmi_cd01_component_ops = {
72-
.bind = lwmi_cd01_component_bind,
74+
static const struct component_ops lwmi_cd_component_ops = {
75+
.bind = lwmi_cd_component_bind,
7376
};
7477

7578
/**
7679
* lwmi_cd01_get_data - Get the data of the specified attribute
77-
* @list: The lenovo-wmi-capdata01 pointer to its cd01_list struct.
80+
* @list: The lenovo-wmi-capdata pointer to its cd_list struct.
7881
* @attribute_id: The capdata attribute ID to be found.
7982
* @output: Pointer to a capdata01 struct to return the data.
8083
*
@@ -83,7 +86,7 @@ static const struct component_ops lwmi_cd01_component_ops = {
8386
*
8487
* Return: 0 on success, or -EINVAL.
8588
*/
86-
int lwmi_cd01_get_data(struct cd01_list *list, u32 attribute_id, struct capdata01 *output)
89+
int lwmi_cd01_get_data(struct cd_list *list, u32 attribute_id, struct capdata01 *output)
8790
{
8891
u8 idx;
8992

@@ -97,17 +100,17 @@ int lwmi_cd01_get_data(struct cd01_list *list, u32 attribute_id, struct capdata0
97100

98101
return -EINVAL;
99102
}
100-
EXPORT_SYMBOL_NS_GPL(lwmi_cd01_get_data, "LENOVO_WMI_CD01");
103+
EXPORT_SYMBOL_NS_GPL(lwmi_cd01_get_data, "LENOVO_WMI_CAPDATA");
101104

102105
/**
103-
* lwmi_cd01_cache() - Cache all WMI data block information
104-
* @priv: lenovo-wmi-capdata01 driver data.
106+
* lwmi_cd_cache() - Cache all WMI data block information
107+
* @priv: lenovo-wmi-capdata driver data.
105108
*
106109
* Loop through each WMI data block and cache the data.
107110
*
108111
* Return: 0 on success, or an error.
109112
*/
110-
static int lwmi_cd01_cache(struct lwmi_cd01_priv *priv)
113+
static int lwmi_cd_cache(struct lwmi_cd_priv *priv)
111114
{
112115
int idx;
113116

@@ -131,17 +134,17 @@ static int lwmi_cd01_cache(struct lwmi_cd01_priv *priv)
131134
}
132135

133136
/**
134-
* lwmi_cd01_alloc() - Allocate a cd01_list struct in drvdata
135-
* @priv: lenovo-wmi-capdata01 driver data.
137+
* lwmi_cd_alloc() - Allocate a cd_list struct in drvdata
138+
* @priv: lenovo-wmi-capdata driver data.
136139
*
137-
* Allocate a cd01_list struct large enough to contain data from all WMI data
140+
* Allocate a cd_list struct large enough to contain data from all WMI data
138141
* blocks provided by the interface.
139142
*
140143
* Return: 0 on success, or an error.
141144
*/
142-
static int lwmi_cd01_alloc(struct lwmi_cd01_priv *priv)
145+
static int lwmi_cd_alloc(struct lwmi_cd_priv *priv)
143146
{
144-
struct cd01_list *list;
147+
struct cd_list *list;
145148
size_t list_size;
146149
int count, ret;
147150

@@ -163,28 +166,28 @@ static int lwmi_cd01_alloc(struct lwmi_cd01_priv *priv)
163166
}
164167

165168
/**
166-
* lwmi_cd01_setup() - Cache all WMI data block information
167-
* @priv: lenovo-wmi-capdata01 driver data.
169+
* lwmi_cd_setup() - Cache all WMI data block information
170+
* @priv: lenovo-wmi-capdata driver data.
168171
*
169-
* Allocate a cd01_list struct large enough to contain data from all WMI data
172+
* Allocate a cd_list struct large enough to contain data from all WMI data
170173
* blocks provided by the interface. Then loop through each data block and
171174
* cache the data.
172175
*
173176
* Return: 0 on success, or an error code.
174177
*/
175-
static int lwmi_cd01_setup(struct lwmi_cd01_priv *priv)
178+
static int lwmi_cd_setup(struct lwmi_cd_priv *priv)
176179
{
177180
int ret;
178181

179-
ret = lwmi_cd01_alloc(priv);
182+
ret = lwmi_cd_alloc(priv);
180183
if (ret)
181184
return ret;
182185

183-
return lwmi_cd01_cache(priv);
186+
return lwmi_cd_cache(priv);
184187
}
185188

186189
/**
187-
* lwmi_cd01_notifier_call() - Call method for lenovo-wmi-capdata01 driver notifier.
190+
* lwmi_cd01_notifier_call() - Call method for cd01 notifier.
188191
* block call chain.
189192
* @nb: The notifier_block registered to lenovo-wmi-events driver.
190193
* @action: Unused.
@@ -199,17 +202,17 @@ static int lwmi_cd01_notifier_call(struct notifier_block *nb, unsigned long acti
199202
void *data)
200203
{
201204
struct acpi_bus_event *event = data;
202-
struct lwmi_cd01_priv *priv;
205+
struct lwmi_cd_priv *priv;
203206
int ret;
204207

205208
if (strcmp(event->device_class, ACPI_AC_CLASS) != 0)
206209
return NOTIFY_DONE;
207210

208-
priv = container_of(nb, struct lwmi_cd01_priv, acpi_nb);
211+
priv = container_of(nb, struct lwmi_cd_priv, acpi_nb);
209212

210213
switch (event->type) {
211214
case ACPI_AC_NOTIFY_STATUS:
212-
ret = lwmi_cd01_cache(priv);
215+
ret = lwmi_cd_cache(priv);
213216
if (ret)
214217
return NOTIFY_BAD;
215218

@@ -230,10 +233,9 @@ static void lwmi_cd01_unregister(void *data)
230233
unregister_acpi_notifier(acpi_nb);
231234
}
232235

233-
static int lwmi_cd01_probe(struct wmi_device *wdev, const void *context)
234-
236+
static int lwmi_cd_probe(struct wmi_device *wdev, const void *context)
235237
{
236-
struct lwmi_cd01_priv *priv;
238+
struct lwmi_cd_priv *priv;
237239
int ret;
238240

239241
priv = devm_kzalloc(&wdev->dev, sizeof(*priv), GFP_KERNEL);
@@ -243,7 +245,7 @@ static int lwmi_cd01_probe(struct wmi_device *wdev, const void *context)
243245
priv->wdev = wdev;
244246
dev_set_drvdata(&wdev->dev, priv);
245247

246-
ret = lwmi_cd01_setup(priv);
248+
ret = lwmi_cd_setup(priv);
247249
if (ret)
248250
return ret;
249251

@@ -257,27 +259,27 @@ static int lwmi_cd01_probe(struct wmi_device *wdev, const void *context)
257259
if (ret)
258260
return ret;
259261

260-
return component_add(&wdev->dev, &lwmi_cd01_component_ops);
262+
return component_add(&wdev->dev, &lwmi_cd_component_ops);
261263
}
262264

263-
static void lwmi_cd01_remove(struct wmi_device *wdev)
265+
static void lwmi_cd_remove(struct wmi_device *wdev)
264266
{
265-
component_del(&wdev->dev, &lwmi_cd01_component_ops);
267+
component_del(&wdev->dev, &lwmi_cd_component_ops);
266268
}
267269

268-
static const struct wmi_device_id lwmi_cd01_id_table[] = {
270+
static const struct wmi_device_id lwmi_cd_id_table[] = {
269271
{ LENOVO_CAPABILITY_DATA_01_GUID, NULL },
270272
{}
271273
};
272274

273-
static struct wmi_driver lwmi_cd01_driver = {
275+
static struct wmi_driver lwmi_cd_driver = {
274276
.driver = {
275-
.name = "lenovo_wmi_cd01",
277+
.name = "lenovo_wmi_capdata",
276278
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
277279
},
278-
.id_table = lwmi_cd01_id_table,
279-
.probe = lwmi_cd01_probe,
280-
.remove = lwmi_cd01_remove,
280+
.id_table = lwmi_cd_id_table,
281+
.probe = lwmi_cd_probe,
282+
.remove = lwmi_cd_remove,
281283
.no_singleton = true,
282284
};
283285

@@ -290,13 +292,13 @@ static struct wmi_driver lwmi_cd01_driver = {
290292
*/
291293
int lwmi_cd01_match(struct device *dev, void *data)
292294
{
293-
return dev->driver == &lwmi_cd01_driver.driver;
295+
return dev->driver == &lwmi_cd_driver.driver;
294296
}
295-
EXPORT_SYMBOL_NS_GPL(lwmi_cd01_match, "LENOVO_WMI_CD01");
297+
EXPORT_SYMBOL_NS_GPL(lwmi_cd01_match, "LENOVO_WMI_CAPDATA");
296298

297-
module_wmi_driver(lwmi_cd01_driver);
299+
module_wmi_driver(lwmi_cd_driver);
298300

299-
MODULE_DEVICE_TABLE(wmi, lwmi_cd01_id_table);
301+
MODULE_DEVICE_TABLE(wmi, lwmi_cd_id_table);
300302
MODULE_AUTHOR("Derek J. Clark <derekjohn.clark@gmail.com>");
301-
MODULE_DESCRIPTION("Lenovo Capability Data 01 WMI Driver");
303+
MODULE_DESCRIPTION("Lenovo Capability Data WMI Driver");
302304
MODULE_LICENSE("GPL");

drivers/platform/x86/lenovo/wmi-capdata01.h renamed to drivers/platform/x86/lenovo/wmi-capdata.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
/* Copyright (C) 2025 Derek J. Clark <derekjohn.clark@gmail.com> */
44

5-
#ifndef _LENOVO_WMI_CAPDATA01_H_
6-
#define _LENOVO_WMI_CAPDATA01_H_
5+
#ifndef _LENOVO_WMI_CAPDATA_H_
6+
#define _LENOVO_WMI_CAPDATA_H_
77

88
#include <linux/types.h>
99

1010
struct device;
11-
struct cd01_list;
11+
struct cd_list;
1212

1313
struct capdata01 {
1414
u32 id;
@@ -19,7 +19,7 @@ struct capdata01 {
1919
u32 max_value;
2020
};
2121

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);
2323
int lwmi_cd01_match(struct device *dev, void *data);
2424

25-
#endif /* !_LENOVO_WMI_CAPDATA01_H_ */
25+
#endif /* !_LENOVO_WMI_CAPDATA_H_ */

drivers/platform/x86/lenovo/wmi-other.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include <linux/types.h>
3535
#include <linux/wmi.h>
3636

37-
#include "wmi-capdata01.h"
37+
#include "wmi-capdata.h"
3838
#include "wmi-events.h"
3939
#include "wmi-gamezone.h"
4040
#include "wmi-helpers.h"
@@ -74,7 +74,10 @@ enum attribute_property {
7474

7575
struct lwmi_om_priv {
7676
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+
7881
struct device *fw_attr_dev;
7982
struct kset *fw_attr_kset;
8083
struct notifier_block nb;
@@ -576,7 +579,7 @@ static void lwmi_om_fw_attr_remove(struct lwmi_om_priv *priv)
576579
static int lwmi_om_master_bind(struct device *dev)
577580
{
578581
struct lwmi_om_priv *priv = dev_get_drvdata(dev);
579-
struct cd01_list *tmp_list;
582+
struct cd_list *tmp_list;
580583
int ret;
581584

582585
ret = component_bind_all(dev, &tmp_list);
@@ -657,7 +660,7 @@ static struct wmi_driver lwmi_other_driver = {
657660

658661
module_wmi_driver(lwmi_other_driver);
659662

660-
MODULE_IMPORT_NS("LENOVO_WMI_CD01");
663+
MODULE_IMPORT_NS("LENOVO_WMI_CAPDATA");
661664
MODULE_IMPORT_NS("LENOVO_WMI_HELPERS");
662665
MODULE_DEVICE_TABLE(wmi, lwmi_other_id_table);
663666
MODULE_AUTHOR("Derek J. Clark <derekjohn.clark@gmail.com>");

0 commit comments

Comments
 (0)