static int __init msi_laptop_input_setup(void) { int err; msi_laptop_input_dev = input_allocate_device(); if (!msi_laptop_input_dev) return -ENOMEM; msi_laptop_input_dev->name = "MSI Laptop hotkeys"; msi_laptop_input_dev->phys = "msi-laptop/input0"; msi_laptop_input_dev->id.bustype = BUS_HOST; err = sparse_keymap_setup(msi_laptop_input_dev, msi_laptop_keymap, NULL); if (err) goto err_free_dev; err = input_register_device(msi_laptop_input_dev); if (err) goto err_free_keymap; return 0; err_free_keymap: sparse_keymap_free(msi_laptop_input_dev); err_free_dev: input_free_device(msi_laptop_input_dev); return err; }
static int __init dell_wmi_aio_init(void) { int err; const char *guid; guid = dell_wmi_aio_find(); if (!guid) { pr_warn("No known WMI GUID found\n"); return -ENXIO; } err = dell_wmi_aio_input_setup(); if (err) return err; err = wmi_install_notify_handler(guid, dell_wmi_aio_notify, NULL); if (err) { pr_err("Unable to register notify handler - %d\n", err); sparse_keymap_free(dell_wmi_aio_input_dev); input_unregister_device(dell_wmi_aio_input_dev); return err; } return 0; }
static int __init msi_wmi_input_setup(void) { int err; msi_wmi_input_dev = input_allocate_device(); if (!msi_wmi_input_dev) return -ENOMEM; msi_wmi_input_dev->name = "MSI WMI hotkeys"; msi_wmi_input_dev->phys = "wmi/input0"; msi_wmi_input_dev->id.bustype = BUS_HOST; err = sparse_keymap_setup(msi_wmi_input_dev, msi_wmi_keymap, NULL); if (err) goto err_free_dev; err = input_register_device(msi_wmi_input_dev); if (err) goto err_free_keymap; memset(last_pressed, 0, sizeof(last_pressed)); return 0; err_free_keymap: sparse_keymap_free(msi_wmi_input_dev); err_free_dev: input_free_device(msi_wmi_input_dev); return err; }
static void asus_input_exit(struct asus_laptop *asus) { if (asus->inputdev) { sparse_keymap_free(asus->inputdev); input_unregister_device(asus->inputdev); } }
static int asus_input_init(struct asus_laptop *asus) { struct input_dev *input; int error; input = input_allocate_device(); if (!input) { pr_info("Unable to allocate input device\n"); return -ENOMEM; } input->name = "Asus Laptop extra buttons"; input->phys = ASUS_LAPTOP_FILE "/input0"; input->id.bustype = BUS_HOST; input->dev.parent = &asus->platform_device->dev; error = sparse_keymap_setup(input, asus_keymap, NULL); if (error) { pr_err("Unable to setup input device keymap\n"); goto err_free_dev; } error = input_register_device(input); if (error) { pr_info("Unable to register input device\n"); goto err_free_keymap; } asus->inputdev = input; return 0; err_free_keymap: sparse_keymap_free(input); err_free_dev: input_free_device(input); return error; }
static int toshiba_acpi_remove(struct acpi_device *acpi_dev, int type) { struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev); remove_toshiba_proc_entries(dev); if (dev->ntfy_supported) { i8042_remove_filter(toshiba_acpi_i8042_filter); cancel_work_sync(&dev->hotkey_work); } if (dev->hotkey_dev) { input_unregister_device(dev->hotkey_dev); sparse_keymap_free(dev->hotkey_dev); } if (dev->bt_rfk) { rfkill_unregister(dev->bt_rfk); rfkill_destroy(dev->bt_rfk); } if (dev->backlight_dev) backlight_device_unregister(dev->backlight_dev); if (dev->illumination_supported) led_classdev_unregister(&dev->led_dev); if (toshiba_acpi) toshiba_acpi = NULL; kfree(dev); return 0; }
static int gb_wmi_input_setup() { int err; gb_wmi_input_dev = input_allocate_device(); if (!gb_wmi_input_dev) return -ENOMEM; gb_wmi_input_dev->name = "GB WMI input device"; gb_wmi_input_dev->phys = "wmi/input0"; gb_wmi_input_dev->id.bustype = BUS_HOST; err = sparse_keymap_setup(gb_wmi_input_dev, gb_wmi_keymap, NULL); if (err) goto err_free_dev; err = input_register_device(gb_wmi_input_dev); if (err) goto err_free_keymap; return 0; err_free_keymap: sparse_keymap_free(gb_wmi_input_dev); err_free_dev: input_free_device(gb_wmi_input_dev); return err; }
static int __init dell_wmi_aio_input_setup(void) { int err; dell_wmi_aio_input_dev = input_allocate_device(); if (!dell_wmi_aio_input_dev) return -ENOMEM; dell_wmi_aio_input_dev->name = "Dell AIO WMI hotkeys"; dell_wmi_aio_input_dev->phys = "wmi/input0"; dell_wmi_aio_input_dev->id.bustype = BUS_HOST; err = sparse_keymap_setup(dell_wmi_aio_input_dev, dell_wmi_aio_keymap, NULL); if (err) { pr_err("Unable to setup input device keymap\n"); goto err_free_dev; } err = input_register_device(dell_wmi_aio_input_dev); if (err) { pr_info("Unable to register input device\n"); goto err_free_keymap; } return 0; err_free_keymap: sparse_keymap_free(dell_wmi_aio_input_dev); err_free_dev: input_free_device(dell_wmi_aio_input_dev); return err; }
static void __exit gb_wmi_exit(void) { if (wmi_has_guid(GB_WMI_EVENT_GUID)) { wmi_remove_notify_handler(GB_WMI_EVENT_GUID); sparse_keymap_free(gb_wmi_input_dev); input_unregister_device(gb_wmi_input_dev); } }
static void __exit dell_wmi_aio_exit(void) { const char *guid; guid = dell_wmi_aio_find(); wmi_remove_notify_handler(guid); sparse_keymap_free(dell_wmi_aio_input_dev); input_unregister_device(dell_wmi_aio_input_dev); }
static void __exit msi_wmi_exit(void) { if (wmi_has_guid(MSIWMI_EVENT_GUID)) { wmi_remove_notify_handler(MSIWMI_EVENT_GUID); sparse_keymap_free(msi_wmi_input_dev); input_unregister_device(msi_wmi_input_dev); backlight_device_unregister(backlight); } }
static int __devexit dm355evm_keys_remove(struct platform_device *pdev) { struct dm355evm_keys *keys = platform_get_drvdata(pdev); free_irq(keys->irq, keys); sparse_keymap_free(keys->input); input_unregister_device(keys->input); kfree(keys); return 0; }
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 toshiba_wmi_input_setup(void) { acpi_status status; int err; toshiba_wmi_input_dev = input_allocate_device(); if (!toshiba_wmi_input_dev) return -ENOMEM; toshiba_wmi_input_dev->name = "Toshiba WMI hotkeys"; toshiba_wmi_input_dev->phys = "wmi/input0"; toshiba_wmi_input_dev->id.bustype = BUS_HOST; err = sparse_keymap_setup(toshiba_wmi_input_dev, toshiba_wmi_keymap, NULL); if (err) goto err_free_dev; status = wmi_install_notify_handler(TOSHIBA_WMI_EVENT_GUID, toshiba_wmi_notify, NULL); if (ACPI_FAILURE(status)) { err = -EIO; goto err_free_keymap; } err = input_register_device(toshiba_wmi_input_dev); if (err) goto err_remove_notifier; return 0; err_remove_notifier: wmi_remove_notify_handler(TOSHIBA_WMI_EVENT_GUID); err_free_keymap: sparse_keymap_free(toshiba_wmi_input_dev); err_free_dev: input_free_device(toshiba_wmi_input_dev); return err; }
static int __devinit dm355evm_keys_probe(struct platform_device *pdev) { struct dm355evm_keys *keys; struct input_dev *input; int status; /* allocate instance struct and input dev */ keys = kzalloc(sizeof *keys, GFP_KERNEL); input = input_allocate_device(); if (!keys || !input) { status = -ENOMEM; goto fail1; } keys->dev = &pdev->dev; keys->input = input; /* set up "threaded IRQ handler" */ status = platform_get_irq(pdev, 0); if (status < 0) goto fail1; keys->irq = status; input_set_drvdata(input, keys); input->name = "DM355 EVM Controls"; input->phys = "dm355evm/input0"; input->dev.parent = &pdev->dev; input->id.bustype = BUS_I2C; input->id.product = 0x0355; input->id.version = dm355evm_msp_read(DM355EVM_MSP_FIRMREV); status = sparse_keymap_setup(input, dm355evm_keys, NULL); if (status) goto fail1; /* REVISIT: flush the event queue? */ status = request_threaded_irq(keys->irq, NULL, dm355evm_keys_irq, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, dev_name(&pdev->dev), keys); if (status < 0) goto fail2; /* register */ status = input_register_device(input); if (status < 0) goto fail3; platform_set_drvdata(pdev, keys); return 0; fail3: free_irq(keys->irq, keys); fail2: sparse_keymap_free(input); fail1: input_free_device(input); kfree(keys); dev_err(&pdev->dev, "can't register, err %d\n", status); return status; }
static void toshiba_wmi_input_destroy(void) { wmi_remove_notify_handler(TOSHIBA_WMI_EVENT_GUID); sparse_keymap_free(toshiba_wmi_input_dev); input_unregister_device(toshiba_wmi_input_dev); }
static int __devinit toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev) { acpi_status status; acpi_handle ec_handle, handle; int error; u32 hci_result; dev->hotkey_dev = input_allocate_device(); if (!dev->hotkey_dev) { pr_info("Unable to register input device\n"); return -ENOMEM; } dev->hotkey_dev->name = "Toshiba input device"; dev->hotkey_dev->phys = "toshiba_acpi/input0"; dev->hotkey_dev->id.bustype = BUS_HOST; error = sparse_keymap_setup(dev->hotkey_dev, toshiba_acpi_keymap, NULL); if (error) goto err_free_dev; /* */ status = AE_ERROR; ec_handle = ec_get_handle(); if (ec_handle) status = acpi_get_handle(ec_handle, "NTFY", &handle); if (ACPI_SUCCESS(status)) { INIT_WORK(&dev->hotkey_work, toshiba_acpi_hotkey_work); error = i8042_install_filter(toshiba_acpi_i8042_filter); if (error) { pr_err("Error installing key filter\n"); goto err_free_keymap; } dev->ntfy_supported = 1; } /* */ status = acpi_get_handle(dev->acpi_dev->handle, "INFO", &handle); if (ACPI_SUCCESS(status)) { dev->info_supported = 1; } else { hci_write1(dev, HCI_SYSTEM_EVENT, 1, &hci_result); if (hci_result == HCI_SUCCESS) dev->system_event_supported = 1; } if (!dev->info_supported && !dev->system_event_supported) { pr_warn("No hotkey query interface found\n"); goto err_remove_filter; } status = acpi_evaluate_object(dev->acpi_dev->handle, "ENAB", NULL, NULL); if (ACPI_FAILURE(status)) { pr_info("Unable to enable hotkeys\n"); error = -ENODEV; goto err_remove_filter; } error = input_register_device(dev->hotkey_dev); if (error) { pr_info("Unable to register input device\n"); goto err_remove_filter; } hci_write1(dev, HCI_HOTKEY_EVENT, HCI_HOTKEY_ENABLE, &hci_result); return 0; err_remove_filter: if (dev->ntfy_supported) i8042_remove_filter(toshiba_acpi_i8042_filter); err_free_keymap: sparse_keymap_free(dev->hotkey_dev); err_free_dev: input_free_device(dev->hotkey_dev); dev->hotkey_dev = NULL; return error; }
static void msi_laptop_input_destroy(void) { sparse_keymap_free(msi_laptop_input_dev); input_unregister_device(msi_laptop_input_dev); }
static int __devinit toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev) { acpi_status status; acpi_handle ec_handle, handle; int error; u32 hci_result; dev->hotkey_dev = input_allocate_device(); if (!dev->hotkey_dev) { pr_info("Unable to register input device\n"); return -ENOMEM; } dev->hotkey_dev->name = "Toshiba input device"; dev->hotkey_dev->phys = "toshiba_acpi/input0"; dev->hotkey_dev->id.bustype = BUS_HOST; error = sparse_keymap_setup(dev->hotkey_dev, toshiba_acpi_keymap, NULL); if (error) goto err_free_dev; /* * For some machines the SCI responsible for providing hotkey * notification doesn't fire. We can trigger the notification * whenever the Fn key is pressed using the NTFY method, if * supported, so if it's present set up an i8042 key filter * for this purpose. */ status = AE_ERROR; ec_handle = ec_get_handle(); if (ec_handle) status = acpi_get_handle(ec_handle, "NTFY", &handle); if (ACPI_SUCCESS(status)) { INIT_WORK(&dev->hotkey_work, toshiba_acpi_hotkey_work); error = i8042_install_filter(toshiba_acpi_i8042_filter); if (error) { pr_err("Error installing key filter\n"); goto err_free_keymap; } dev->ntfy_supported = 1; } /* * Determine hotkey query interface. Prefer using the INFO * method when it is available. */ status = acpi_get_handle(dev->acpi_dev->handle, "INFO", &handle); if (ACPI_SUCCESS(status)) { dev->info_supported = 1; } else { hci_write1(dev, HCI_SYSTEM_EVENT, 1, &hci_result); if (hci_result == HCI_SUCCESS) dev->system_event_supported = 1; } if (!dev->info_supported && !dev->system_event_supported) { pr_warn("No hotkey query interface found\n"); goto err_remove_filter; } status = acpi_evaluate_object(dev->acpi_dev->handle, "ENAB", NULL, NULL); if (ACPI_FAILURE(status)) { pr_info("Unable to enable hotkeys\n"); error = -ENODEV; goto err_remove_filter; } error = input_register_device(dev->hotkey_dev); if (error) { pr_info("Unable to register input device\n"); goto err_remove_filter; } hci_write1(dev, HCI_HOTKEY_EVENT, HCI_HOTKEY_ENABLE, &hci_result); return 0; err_remove_filter: if (dev->ntfy_supported) i8042_remove_filter(toshiba_acpi_i8042_filter); err_free_keymap: sparse_keymap_free(dev->hotkey_dev); err_free_dev: input_free_device(dev->hotkey_dev); dev->hotkey_dev = NULL; return error; }