// SPDX-License-Identifier: GPL-2.0-or-later /* * Lenovo Capability Data 01 WMI Data Block driver. * * Lenovo Capability Data 01 provides information on tunable attributes used by * the "Other Mode" WMI interface. The data includes if the attribute is * supported by the hardware, the default_value, max_value, min_value, and step * increment. Each attribute has multiple pages, one for each of the thermal * modes managed by the Gamezone interface. * * Copyright (C) 2025 Derek J. Clark <derekjohn.clark@gmail.com>
*/
/** * lwmi_cd01_component_bind() - Bind component to master device. * @cd01_dev: Pointer to the lenovo-wmi-capdata01 driver parent device. * @om_dev: Pointer to the lenovo-wmi-other driver parent device. * @data: capdata01_list object pointer used to return the capability data. * * On lenovo-wmi-other's master bind, provide a pointer to the local capdata01 * list. This is used to call lwmi_cd01_get_data to look up attribute data * from the lenovo-wmi-other driver. * * Return: 0
*/ staticint lwmi_cd01_component_bind(struct device *cd01_dev, struct device *om_dev, void *data)
{ struct lwmi_cd01_priv *priv = dev_get_drvdata(cd01_dev); struct cd01_list **cd01_list = data;
/** * lwmi_cd01_get_data - Get the data of the specified attribute * @list: The lenovo-wmi-capdata01 pointer to its cd01_list struct. * @attribute_id: The capdata attribute ID to be found. * @output: Pointer to a capdata01 struct to return the data. * * Retrieves the capability data 01 struct pointer for the given * attribute for its specified thermal mode. * * Return: 0 on success, or -EINVAL.
*/ int lwmi_cd01_get_data(struct cd01_list *list, u32 attribute_id, struct capdata01 *output)
{
u8 idx;
/** * lwmi_cd01_cache() - Cache all WMI data block information * @priv: lenovo-wmi-capdata01 driver data. * * Loop through each WMI data block and cache the data. * * Return: 0 on success, or an error.
*/ staticint lwmi_cd01_cache(struct lwmi_cd01_priv *priv)
{ int idx;
guard(mutex)(&priv->list->list_mutex); for (idx = 0; idx < priv->list->count; idx++) { union acpi_object *ret_obj __free(kfree) = NULL;
ret_obj = wmidev_block_query(priv->wdev, idx); if (!ret_obj) return -ENODEV;
if (ret_obj->type != ACPI_TYPE_BUFFER ||
ret_obj->buffer.length < sizeof(priv->list->data[idx])) continue;
/** * lwmi_cd01_alloc() - Allocate a cd01_list struct in drvdata * @priv: lenovo-wmi-capdata01 driver data. * * Allocate a cd01_list struct large enough to contain data from all WMI data * blocks provided by the interface. * * Return: 0 on success, or an error.
*/ staticint lwmi_cd01_alloc(struct lwmi_cd01_priv *priv)
{ struct cd01_list *list;
size_t list_size; int count, ret;
list = devm_kzalloc(&priv->wdev->dev, list_size, GFP_KERNEL); if (!list) return -ENOMEM;
ret = devm_mutex_init(&priv->wdev->dev, &list->list_mutex); if (ret) return ret;
list->count = count;
priv->list = list;
return 0;
}
/** * lwmi_cd01_setup() - Cache all WMI data block information * @priv: lenovo-wmi-capdata01 driver data. * * Allocate a cd01_list struct large enough to contain data from all WMI data * blocks provided by the interface. Then loop through each data block and * cache the data. * * Return: 0 on success, or an error code.
*/ staticint lwmi_cd01_setup(struct lwmi_cd01_priv *priv)
{ int ret;
ret = lwmi_cd01_alloc(priv); if (ret) return ret;
return lwmi_cd01_cache(priv);
}
/** * lwmi_cd01_notifier_call() - Call method for lenovo-wmi-capdata01 driver notifier. * block call chain. * @nb: The notifier_block registered to lenovo-wmi-events driver. * @action: Unused. * @data: The ACPI event. * * For LWMI_EVENT_THERMAL_MODE, set current_mode and notify platform_profile * of a change. * * Return: notifier_block status.
*/ staticint lwmi_cd01_notifier_call(struct notifier_block *nb, unsignedlong action, void *data)
{ struct acpi_bus_event *event = data; struct lwmi_cd01_priv *priv; int ret;
if (strcmp(event->device_class, ACPI_AC_CLASS) != 0) return NOTIFY_DONE;
/** * lwmi_cd01_match() - Match rule for the master driver. * @dev: Pointer to the capability data 01 parent device. * @data: Unused void pointer for passing match criteria. * * Return: int.
*/ int lwmi_cd01_match(struct device *dev, void *data)
{ return dev->driver == &lwmi_cd01_driver.driver;
}
EXPORT_SYMBOL_NS_GPL(lwmi_cd01_match, "LENOVO_WMI_CD01");
module_wmi_driver(lwmi_cd01_driver);
MODULE_DEVICE_TABLE(wmi, lwmi_cd01_id_table);
MODULE_AUTHOR("Derek J. Clark ");
MODULE_DESCRIPTION("Lenovo Capability Data 01 WMI Driver");
MODULE_LICENSE("GPL");
Messung V0.5
¤ Dauer der Verarbeitung: 0.29 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.