示例#1
0
static int __init lenovo_sl_laptop_init(void)
{
	int ret;
	acpi_status status;

	hkey_handle = ec0_handle = NULL;

	if (acpi_disabled)
		return -ENODEV;

	lensl_wq = create_singlethread_workqueue(LENSL_WORKQUEUE_NAME);
	if (!lensl_wq) {
		vdbg_printk(LENSL_ERR, "Failed to create a workqueue\n");
		return -ENOMEM;
	}

	status = acpi_get_handle(NULL, LENSL_HKEY, &hkey_handle);
	if (ACPI_FAILURE(status)) {
		vdbg_printk(LENSL_ERR,
			"Failed to get ACPI handle for %s\n", LENSL_HKEY);
		return -ENODEV;
	}
	status = acpi_get_handle(NULL, LENSL_EC0, &ec0_handle);
	if (ACPI_FAILURE(status)) {
		vdbg_printk(LENSL_ERR,
			"Failed to get ACPI handle for %s\n", LENSL_EC0);
		return -ENODEV;
	}

	lensl_pdev = platform_device_register_simple(LENSL_DRVR_NAME, -1,
							NULL, 0);
	if (IS_ERR(lensl_pdev)) {
		ret = PTR_ERR(lensl_pdev);
		lensl_pdev = NULL;
		vdbg_printk(LENSL_ERR, "Failed to register platform device\n");
		return ret;
	}

	ret = hkey_inputdev_init();
	if (ret)
		return -ENODEV;

	radio_init(LENSL_BLUETOOTH);
	radio_init(LENSL_WWAN);
	radio_init(LENSL_UWB);

	led_init();
	mutex_init(&hkey_poll_mutex);
	hwmon_init();

	if (debug_ec)
		lenovo_sl_procfs_init();

	vdbg_printk(LENSL_INFO, "Loaded Lenovo ThinkPad SL Series driver\n");
	return 0;
}
static int __init lenovo_sl_laptop_init(void)
{
	int ret;
	acpi_status status;

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
	if (!acpi_video_backlight_support())
		control_backlight = 1;
#endif

	hkey_handle = ec0_handle = NULL;

	if (acpi_disabled)
		return -ENODEV;

	lensl_wq = create_singlethread_workqueue(LENSL_WORKQUEUE_NAME);
	if (!lensl_wq) {
		vdbg_printk(LENSL_ERR, "Failed to create a workqueue\n");
		return -ENOMEM;
	}

	status = acpi_get_handle(NULL, LENSL_HKEY, &hkey_handle);
	if (ACPI_FAILURE(status)) {
		vdbg_printk(LENSL_ERR,
			"Failed to get ACPI handle for %s\n", LENSL_HKEY);
		return -ENODEV;
	}
	status = acpi_get_handle(NULL, LENSL_EC0, &ec0_handle);
	if (ACPI_FAILURE(status)) {
		vdbg_printk(LENSL_ERR,
			"Failed to get ACPI handle for %s\n", LENSL_EC0);
		return -ENODEV;
	}

	lensl_pdev = platform_device_register_simple(LENSL_DRVR_NAME, -1,
							NULL, 0);
	if (IS_ERR(lensl_pdev)) {
		ret = PTR_ERR(lensl_pdev);
		lensl_pdev = NULL;
		vdbg_printk(LENSL_ERR, "Failed to register platform device\n");
		return ret;
	}

	ret = hkey_inputdev_init();
	if (ret)
		return -ENODEV;

	bluetooth_init();
	if (control_backlight)
		backlight_init();

	led_init();
	mutex_init(&hkey_poll_mutex);
	hkey_poll_start();
	hwmon_init();

	if (debug_ec)
		lenovo_sl_procfs_init();

	vdbg_printk(LENSL_INFO, "Loaded Lenovo ThinkPad SL Series driver\n");
	return 0;
}