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

Source file repositories/reference/linux-study-clean/drivers/platform/x86/lenovo/wmi-helpers.c

File Facts

System
Linux kernel
Corpus path
drivers/platform/x86/lenovo/wmi-helpers.c
Extension
.c
Size
5900 bytes
Lines
191
Domain
Driver Families
Bucket
drivers/platform
Inferred role
Driver Families: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

switch (ret_obj->type) {
		/*
		 * The ACPI method may simply return a buffer when a u32
		 * is expected. This is valid on Windows as its WMI-ACPI
		 * driver converts everything to a common buffer.
		 */
		case ACPI_TYPE_BUFFER:
			if (ret_obj->buffer.length < sizeof(u32))
				return -ENXIO;

			*retval = get_unaligned_le32(ret_obj->buffer.pointer);
			return 0;
		case ACPI_TYPE_INTEGER:
			*retval = (u32)ret_obj->integer.value;
			return 0;
		default:
			return -ENXIO;
		}
	}

	return 0;
};
EXPORT_SYMBOL_NS_GPL(lwmi_dev_evaluate_int, "LENOVO_WMI_HELPERS");

/**
 * lwmi_tm_register_notifier() - Add a notifier to the blocking notifier chain
 * @nb: The notifier_block struct to register
 *
 * Call blocking_notifier_chain_register to register the notifier block to the
 * thermal mode notifier chain.
 *
 * Return: 0 on success, %-EEXIST on error.
 */
int lwmi_tm_register_notifier(struct notifier_block *nb)
{
	return blocking_notifier_chain_register(&tm_chain_head, nb);
}
EXPORT_SYMBOL_NS_GPL(lwmi_tm_register_notifier, "LENOVO_WMI_HELPERS");

/**
 * lwmi_tm_unregister_notifier() - Remove a notifier from the blocking notifier
 * chain.
 * @nb: The notifier_block struct to register
 *
 * Call blocking_notifier_chain_unregister to unregister the notifier block from the
 * thermal mode notifier chain.
 *
 * Return: 0 on success, %-ENOENT on error.
 */
int lwmi_tm_unregister_notifier(struct notifier_block *nb)
{
	return blocking_notifier_chain_unregister(&tm_chain_head, nb);
}
EXPORT_SYMBOL_NS_GPL(lwmi_tm_unregister_notifier, "LENOVO_WMI_HELPERS");

/**
 * devm_lwmi_tm_unregister_notifier() - Remove a notifier from the blocking
 * notifier chain.
 * @data: Void pointer to the notifier_block struct to register.
 *
 * Call lwmi_tm_unregister_notifier to unregister the notifier block from the
 * thermal mode notifier chain.
 *
 * Return: 0 on success, %-ENOENT on error.
 */
static void devm_lwmi_tm_unregister_notifier(void *data)
{
	struct notifier_block *nb = data;

	lwmi_tm_unregister_notifier(nb);
}

/**
 * devm_lwmi_tm_register_notifier() - Add a notifier to the blocking notifier
 * chain.
 * @dev: The parent device of the notifier_block struct.
 * @nb: The notifier_block struct to register
 *
 * Call lwmi_tm_register_notifier to register the notifier block to the
 * thermal mode notifier chain. Then add devm_lwmi_tm_unregister_notifier
 * as a device managed action to automatically unregister the notifier block
 * upon parent device removal.
 *
 * Return: 0 on success, or an error code.
 */
int devm_lwmi_tm_register_notifier(struct device *dev,
				   struct notifier_block *nb)
{
	int ret;

Annotation

Implementation Notes