drivers/platform/x86/asus-wmi.c

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

File Facts

System
Linux kernel
Corpus path
drivers/platform/x86/asus-wmi.c
Extension
.c
Size
142849 bytes
Lines
5407
Domain
Driver Families
Bucket
drivers/platform
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern 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

static const struct file_operations asus_wmi_debugfs_io_ops = {
	.owner = THIS_MODULE,
	.open = asus_wmi_debugfs_open,
	.read = seq_read,
	.llseek = seq_lseek,
	.release = single_release,
};

static void asus_wmi_debugfs_exit(struct asus_wmi *asus)
{
	debugfs_remove_recursive(asus->debug.root);
}

static void asus_wmi_debugfs_init(struct asus_wmi *asus)
{
	int i;

	asus->debug.root = debugfs_create_dir(asus->driver->name, NULL);

	debugfs_create_x32("method_id", S_IRUGO | S_IWUSR, asus->debug.root,
			   &asus->debug.method_id);

	debugfs_create_x32("dev_id", S_IRUGO | S_IWUSR, asus->debug.root,
			   &asus->debug.dev_id);

	debugfs_create_x32("ctrl_param", S_IRUGO | S_IWUSR, asus->debug.root,
			   &asus->debug.ctrl_param);

	for (i = 0; i < ARRAY_SIZE(asus_wmi_debug_files); i++) {
		struct asus_wmi_debugfs_node *node = &asus_wmi_debug_files[i];

		node->asus = asus;
		debugfs_create_file(node->name, S_IFREG | S_IRUGO,
				    asus->debug.root, node,
				    &asus_wmi_debugfs_io_ops);
	}
}

/* Init / exit ****************************************************************/

static int asus_wmi_add(struct platform_device *pdev)
{
	struct platform_driver *pdrv = to_platform_driver(pdev->dev.driver);
	struct asus_wmi_driver *wdrv = to_asus_wmi_driver(pdrv);
	struct asus_wmi *asus;
	acpi_status status;
	int err;
	u32 result;

	asus = kzalloc_obj(struct asus_wmi);
	if (!asus)
		return -ENOMEM;

	asus->driver = wdrv;
	asus->platform_device = pdev;
	wdrv->platform_device = pdev;
	platform_set_drvdata(asus->platform_device, asus);

	if (wdrv->detect_quirks)
		wdrv->detect_quirks(asus->driver);

	err = asus_wmi_platform_init(asus);
	if (err)
		goto fail_platform;

	if (use_ally_mcu_hack == ASUS_WMI_ALLY_MCU_HACK_INIT) {
		if (acpi_has_method(NULL, ASUS_USB0_PWR_EC0_CSEE)
					&& dmi_check_system(asus_rog_ally_device))
			use_ally_mcu_hack = ASUS_WMI_ALLY_MCU_HACK_ENABLED;
		if (dmi_match(DMI_BOARD_NAME, "RC71")) {
			/*
			 * These steps ensure the device is in a valid good state, this is
			 * especially important for the Ally 1 after a reboot.
			 */
			acpi_execute_simple_method(NULL, ASUS_USB0_PWR_EC0_CSEE,
						   ASUS_USB0_PWR_EC0_CSEE_ON);
			msleep(ASUS_USB0_PWR_EC0_CSEE_WAIT);
		}
	}

	/* ensure defaults for tunables */
#if IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS)
	asus->ppt_pl2_sppt = 5;
	asus->ppt_pl1_spl = 5;
	asus->ppt_apu_sppt = 5;
	asus->ppt_platform_sppt = 5;
	asus->ppt_fppt = 5;
	asus->nv_dynamic_boost = 5;
	asus->nv_temp_target = 75;

Annotation

Implementation Notes