static int __init msi_wmi_init(void) { int err; int i; for (i = 0; i < ARRAY_SIZE(event_wmis); i++) { if (!wmi_has_guid(event_wmis[i].guid)) continue; err = msi_wmi_input_setup(); if (err) { pr_err("Unable to setup input device\n"); return err; } err = wmi_install_notify_handler(event_wmis[i].guid, msi_wmi_notify, NULL); if (ACPI_FAILURE(err)) { pr_err("Unable to setup WMI notify handler\n"); goto err_free_input; } pr_debug("Event handler installed\n"); event_wmi = &event_wmis[i]; break; } if (wmi_has_guid(MSIWMI_BIOS_GUID) && acpi_video_get_backlight_type() == acpi_backlight_vendor) { err = msi_wmi_backlight_setup(); if (err) { pr_err("Unable to setup backlight device\n"); goto err_uninstall_handler; } pr_debug("Backlight device created\n"); } if (!event_wmi && !backlight) { pr_err("This machine doesn't have neither MSI-hotkeys nor backlight through WMI\n"); return -ENODEV; } return 0; err_uninstall_handler: if (event_wmi) wmi_remove_notify_handler(event_wmi->guid); err_free_input: if (event_wmi) input_unregister_device(msi_wmi_input_dev); return err; }
static int __init msi_wmi_init(void) { int err; if (!wmi_has_guid(MSIWMI_EVENT_GUID)) { pr_err("This machine doesn't have MSI-hotkeys through WMI\n"); return -ENODEV; } err = wmi_install_notify_handler(MSIWMI_EVENT_GUID, msi_wmi_notify, NULL); if (ACPI_FAILURE(err)) return -EINVAL; err = msi_wmi_input_setup(); if (err) goto err_uninstall_notifier; if (!acpi_video_backlight_support()) { struct backlight_properties props; memset(&props, 0, sizeof(struct backlight_properties)); props.type = BACKLIGHT_PLATFORM; props.max_brightness = ARRAY_SIZE(backlight_map) - 1; backlight = backlight_device_register(DRV_NAME, NULL, NULL, &msi_backlight_ops, &props); if (IS_ERR(backlight)) { err = PTR_ERR(backlight); goto err_free_input; } err = bl_get(NULL); if (err < 0) goto err_free_backlight; backlight->props.brightness = err; } pr_debug("Event handler installed\n"); return 0; err_free_backlight: backlight_device_unregister(backlight); err_free_input: sparse_keymap_free(msi_wmi_input_dev); input_unregister_device(msi_wmi_input_dev); err_uninstall_notifier: wmi_remove_notify_handler(MSIWMI_EVENT_GUID); return err; }
static int __init msi_wmi_init(void) { int err; if (!wmi_has_guid(MSIWMI_EVENT_GUID)) { printk(KERN_ERR "This machine doesn't have MSI-hotkeys through WMI\n"); return -ENODEV; } err = wmi_install_notify_handler(MSIWMI_EVENT_GUID, msi_wmi_notify, NULL); if (err) return -EINVAL; err = msi_wmi_input_setup(); if (err) goto err_uninstall_notifier; if (!acpi_video_backlight_support()) { backlight = backlight_device_register(DRV_NAME, NULL, NULL, &msi_backlight_ops); if (IS_ERR(backlight)) goto err_free_input; backlight->props.max_brightness = ARRAY_SIZE(backlight_map) - 1; err = bl_get(NULL); if (err < 0) goto err_free_backlight; backlight->props.brightness = err; } dprintk("Event handler installed\n"); return 0; err_free_backlight: backlight_device_unregister(backlight); err_free_input: input_unregister_device(msi_wmi_input_dev); err_uninstall_notifier: wmi_remove_notify_handler(MSIWMI_EVENT_GUID); return err; }