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 intel_hid_input_setup(struct platform_device *device) { struct intel_hid_priv *priv = dev_get_drvdata(&device->dev); int ret; priv->input_dev = input_allocate_device(); if (!priv->input_dev) return -ENOMEM; ret = sparse_keymap_setup(priv->input_dev, intel_hid_keymap, NULL); if (ret) goto err_free_device; priv->input_dev->dev.parent = &device->dev; priv->input_dev->name = "Intel HID events"; priv->input_dev->id.bustype = BUS_HOST; set_bit(KEY_RFKILL, priv->input_dev->keybit); ret = input_register_device(priv->input_dev); if (ret) goto err_free_device; return 0; err_free_device: input_free_device(priv->input_dev); return ret; }
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 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 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 hp_wmi_input_setup(void) { acpi_status status; int err, val; hp_wmi_input_dev = input_allocate_device(); if (!hp_wmi_input_dev) return -ENOMEM; hp_wmi_input_dev->name = "HP WMI hotkeys"; hp_wmi_input_dev->phys = "wmi/input0"; hp_wmi_input_dev->id.bustype = BUS_HOST; __set_bit(EV_SW, hp_wmi_input_dev->evbit); /* Dock */ val = hp_wmi_hw_state(HPWMI_DOCK_MASK); if (!(val < 0)) { __set_bit(SW_DOCK, hp_wmi_input_dev->swbit); input_report_switch(hp_wmi_input_dev, SW_DOCK, val); } /* Tablet mode */ val = hp_wmi_hw_state(HPWMI_TABLET_MASK); if (!(val < 0)) { __set_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit); input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE, val); } err = sparse_keymap_setup(hp_wmi_input_dev, hp_wmi_keymap, NULL); if (err) goto err_free_dev; /* Set initial hardware state */ input_sync(hp_wmi_input_dev); if (!hp_wmi_bios_2009_later() && hp_wmi_bios_2008_later()) hp_wmi_enable_hotkeys(); status = wmi_install_notify_handler(HPWMI_EVENT_GUID, hp_wmi_notify, NULL); if (ACPI_FAILURE(status)) { err = -EIO; goto err_free_dev; } err = input_register_device(hp_wmi_input_dev); if (err) goto err_uninstall_notifier; return 0; err_uninstall_notifier: wmi_remove_notify_handler(HPWMI_EVENT_GUID); err_free_dev: input_free_device(hp_wmi_input_dev); return err; }
static int intel_hid_input_setup(struct platform_device *device) { struct intel_hid_priv *priv = dev_get_drvdata(&device->dev); int ret; priv->input_dev = devm_input_allocate_device(&device->dev); if (!priv->input_dev) return -ENOMEM; ret = sparse_keymap_setup(priv->input_dev, intel_hid_keymap, NULL); if (ret) return ret; priv->input_dev->name = "Intel HID events"; priv->input_dev->id.bustype = BUS_HOST; return input_register_device(priv->input_dev); }
static int intel_vbtn_input_setup(struct platform_device *device) { struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev); int ret; priv->input_dev = devm_input_allocate_device(&device->dev); if (!priv->input_dev) return -ENOMEM; ret = sparse_keymap_setup(priv->input_dev, intel_vbtn_keymap, NULL); if (ret) return ret; priv->input_dev->dev.parent = &device->dev; priv->input_dev->name = "Intel Virtual Button driver"; priv->input_dev->id.bustype = BUS_HOST; return input_register_device(priv->input_dev); }
static int intel_button_array_input_setup(struct platform_device *device) { struct intel_hid_priv *priv = dev_get_drvdata(&device->dev); int ret; /* Setup input device for 5 button array */ priv->array = devm_input_allocate_device(&device->dev); if (!priv->array) return -ENOMEM; ret = sparse_keymap_setup(priv->array, intel_array_keymap, NULL); if (ret) return ret; priv->array->name = "Intel HID 5 button array"; priv->array->id.bustype = BUS_HOST; return input_register_device(priv->array); }
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 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 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; }