static int gpio_event_probe(struct platform_device *pdev) { int err; struct gpio_event *ip; struct gpio_event_platform_data *event_info; int dev_count = 1; int i; int registered = 0; event_info = pdev->dev.platform_data; if (event_info == NULL) { KEY_LOGE("KEY_ERR: %s: No pdata\n", __func__); return -ENODEV; } if ((!event_info->name && !event_info->names[0]) || !event_info->info || !event_info->info_count) { KEY_LOGE("KEY_ERR: %s: Incomplete pdata\n", __func__); return -ENODEV; } if (!event_info->name) while (event_info->names[dev_count]) dev_count++; ip = kzalloc(sizeof(*ip) + sizeof(ip->state[0]) * event_info->info_count + sizeof(*ip->input_devs) + sizeof(ip->input_devs->dev[0]) * dev_count, GFP_KERNEL); if (ip == NULL) { err = -ENOMEM; KEY_LOGE("KEY_ERR: %s: Failed to allocate private data\n", __func__); goto err_kp_alloc_failed; } ip->input_devs = (void*)&ip->state[event_info->info_count]; platform_set_drvdata(pdev, ip); for (i = 0; i < dev_count; i++) { struct input_dev *input_dev = input_allocate_device(); if (input_dev == NULL) { err = -ENOMEM; KEY_LOGE("KEY_ERR: %s: " "Failed to allocate input device\n", __func__); goto err_input_dev_alloc_failed; } input_set_drvdata(input_dev, ip); input_dev->name = event_info->name ? event_info->name : event_info->names[i]; input_dev->event = gpio_input_event; ip->input_devs->dev[i] = input_dev; #ifdef CONFIG_TOUCHSCREEN_SYNAPTICS_SWEEP2WAKE if (!strcmp(input_dev->name, "keypad_8960")) { sweep2wake_setdev(input_dev); printk(KERN_INFO "[sweep2wake]: set device %s\n", input_dev->name); } #endif } ip->input_devs->count = dev_count; ip->info = event_info; if (event_info->power) { #ifdef CONFIG_HAS_EARLYSUSPEND ip->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; ip->early_suspend.suspend = gpio_event_suspend; ip->early_suspend.resume = gpio_event_resume; register_early_suspend(&ip->early_suspend); #endif ip->info->power(ip->info, 1); } err = gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_INIT); if (err) goto err_call_all_func_failed; for (i = 0; i < dev_count; i++) { err = input_register_device(ip->input_devs->dev[i]); if (err) { KEY_LOGE("KEY_ERR: %s: Unable to register %s " "input device\n", __func__, ip->input_devs->dev[i]->name); goto err_input_register_device_failed; } registered++; } return 0; err_input_register_device_failed: gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_UNINIT); err_call_all_func_failed: if (event_info->power) { #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&ip->early_suspend); #endif ip->info->power(ip->info, 0); } for (i = 0; i < registered; i++) input_unregister_device(ip->input_devs->dev[i]); for (i = dev_count - 1; i >= registered; i--) { input_free_device(ip->input_devs->dev[i]); err_input_dev_alloc_failed: ; } kfree(ip); err_kp_alloc_failed: return err; }
static int gpio_event_sleep(struct platform_device *pdev, pm_message_t state) { struct gpio_event *ip = platform_get_drvdata(pdev); return gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_SUSPEND); }
static int gpio_event_probe(struct platform_device *pdev) { int err; struct gpio_event *ip; struct gpio_event_platform_data *event_info; int dev_count = 1; int i; int registered = 0; event_info = pdev->dev.platform_data; if (event_info == NULL) { pr_err("gpio_event_probe: No pdata\n"); return -ENODEV; } if ((!event_info->name && !event_info->names[0]) || !event_info->info || !event_info->info_count) { pr_err("gpio_event_probe: Incomplete pdata\n"); return -ENODEV; } if (!event_info->name) while (event_info->names[dev_count]) dev_count++; ip = kzalloc(sizeof(*ip) + sizeof(ip->state[0]) * event_info->info_count + sizeof(*ip->input_devs) + sizeof(ip->input_devs->dev[0]) * dev_count, GFP_KERNEL); if (ip == NULL) { err = -ENOMEM; pr_err("gpio_event_probe: Failed to allocate private data\n"); goto err_kp_alloc_failed; } ip->input_devs = (void*)&ip->state[event_info->info_count]; platform_set_drvdata(pdev, ip); for (i = 0; i < dev_count; i++) { struct input_dev *input_dev = input_allocate_device(); if (input_dev == NULL) { err = -ENOMEM; pr_err("gpio_event_probe: " "Failed to allocate input device\n"); goto err_input_dev_alloc_failed; } input_set_drvdata(input_dev, ip); input_dev->name = event_info->name ? event_info->name : event_info->names[i]; input_dev->event = gpio_input_event; ip->input_devs->dev[i] = input_dev; } ip->input_devs->count = dev_count; ip->info = event_info; if (event_info->power) { #ifdef CONFIG_HAS_EARLYSUSPEND ip->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; ip->early_suspend.suspend = gpio_event_suspend; ip->early_suspend.resume = gpio_event_resume; register_early_suspend(&ip->early_suspend); #endif ip->info->power(ip->info, 1); } err = gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_INIT); if (err) goto err_call_all_func_failed; for (i = 0; i < dev_count; i++) { err = input_register_device(ip->input_devs->dev[i]); if (err) { pr_err("gpio_event_probe: Unable to register %s " "input device\n", ip->input_devs->dev[i]->name); goto err_input_register_device_failed; } registered++; } err = device_create_file(&(pdev->dev), &dev_attr_fm_radio); return 0; err_input_register_device_failed: gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_UNINIT); err_call_all_func_failed: if (event_info->power) { #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&ip->early_suspend); #endif ip->info->power(ip->info, 0); } for (i = 0; i < registered; i++) input_unregister_device(ip->input_devs->dev[i]); for (i = dev_count - 1; i >= registered; i--) { input_free_device(ip->input_devs->dev[i]); err_input_dev_alloc_failed: ; } kfree(ip); err_kp_alloc_failed: return err; }
static int __init gpio_event_probe(struct platform_device *pdev) { int err; struct gpio_event *ip; struct input_dev *input_dev; struct gpio_event_platform_data *event_info; event_info = pdev->dev.platform_data; if (event_info == NULL) { pr_err("gpio_event_probe: No pdata\n"); return -ENODEV; } if (event_info->name == NULL || event_info->info == NULL || event_info->info_count == 0) { pr_err("gpio_event_probe: Incomplete pdata\n"); return -ENODEV; } ip = kzalloc(sizeof(*ip) + sizeof(ip->state[0]) * event_info->info_count, GFP_KERNEL); if (ip == NULL) { err = -ENOMEM; pr_err("gpio_event_probe: Failed to allocate private data\n"); goto err_kp_alloc_failed; } platform_set_drvdata(pdev, ip); input_dev = input_allocate_device(); if (input_dev == NULL) { err = -ENOMEM; pr_err("gpio_event_probe: Failed to allocate input device\n"); goto err_input_dev_alloc_failed; } input_set_drvdata(input_dev, ip); ip->input_dev = input_dev; ip->info = event_info; if (event_info->power) { #ifdef CONFIG_HAS_EARLYSUSPEND ip->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; ip->early_suspend.suspend = gpio_event_suspend; ip->early_suspend.resume = gpio_event_resume; register_early_suspend(&ip->early_suspend); #endif ip->info->power(ip->info, 1); } input_dev->name = ip->info->name; input_dev->event = gpio_input_event; err = gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_INIT); if (err) goto err_call_all_func_failed; err = input_register_device(input_dev); if (err) { pr_err("gpio_event_probe: Unable to register %s input device\n", input_dev->name); goto err_input_register_device_failed; } return 0; err_input_register_device_failed: gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_UNINIT); err_call_all_func_failed: if (event_info->power) { #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&ip->early_suspend); #endif ip->info->power(ip->info, 0); } input_free_device(input_dev); err_input_dev_alloc_failed: kfree(ip); err_kp_alloc_failed: return err; }
static int gpio_event_wakeup(struct platform_device *pdev) { struct gpio_event *ip = platform_get_drvdata(pdev); return gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_RESUME); }
static int gpio_event_probe(struct platform_device *pdev) { int err; struct gpio_event *ip; struct gpio_event_platform_data *event_info; int dev_count = 1; int i; int registered = 0; event_info = pdev->dev.platform_data; if (event_info == NULL) { pr_err("gpio_event_probe: No pdata\n"); return -ENODEV; } if ((!event_info->name && !event_info->names[0]) || !event_info->info || !event_info->info_count) { pr_err("gpio_event_probe: Incomplete pdata\n"); return -ENODEV; } if (!event_info->name) while (event_info->names[dev_count]) dev_count++; ip = kzalloc(sizeof(*ip) + sizeof(ip->state[0]) * event_info->info_count + sizeof(*ip->input_devs) + sizeof(ip->input_devs->dev[0]) * dev_count, GFP_KERNEL); if (ip == NULL) { err = -ENOMEM; pr_err("gpio_event_probe: Failed to allocate private data\n"); goto err_kp_alloc_failed; } ip->input_devs = (void*)&ip->state[event_info->info_count]; platform_set_drvdata(pdev, ip); for (i = 0; i < dev_count; i++) { struct input_dev *input_dev = input_allocate_device(); if (input_dev == NULL) { err = -ENOMEM; pr_err("gpio_event_probe: " "Failed to allocate input device\n"); goto err_input_dev_alloc_failed; } input_set_drvdata(input_dev, ip); input_dev->name = event_info->name ? event_info->name : event_info->names[i]; input_dev->event = gpio_input_event; ip->input_devs->dev[i] = input_dev; #ifdef CONFIG_TOUCHSCREEN_SYNAPTICS_SWEEP2WAKE pr_warn("We are here!"); //if (!strcmp(input_dev->name, "keypad_8960")) { //sweep2sleep_setdev(input_dev); //pr_warn("[sweep2wake]: set device %s\n", input_dev->name); //} #endif } ip->input_devs->count = dev_count; ip->info = event_info; if (event_info->power) ip->info->power(ip->info, 1); err = gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_INIT); if (err) goto err_call_all_func_failed; for (i = 0; i < dev_count; i++) { err = input_register_device(ip->input_devs->dev[i]); if (err) { pr_err("gpio_event_probe: Unable to register %s " "input device\n", ip->input_devs->dev[i]->name); goto err_input_register_device_failed; } registered++; } return 0; err_input_register_device_failed: gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_UNINIT); err_call_all_func_failed: if (event_info->power) ip->info->power(ip->info, 0); for (i = 0; i < registered; i++) input_unregister_device(ip->input_devs->dev[i]); for (i = dev_count - 1; i >= registered; i--) { input_free_device(ip->input_devs->dev[i]); err_input_dev_alloc_failed: ; } kfree(ip); err_kp_alloc_failed: return err; }
static void __maybe_unused gpio_event_resume(struct gpio_event *ip) { if (ip->info->power) ip->info->power(ip->info, 1); gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_RESUME); }
static void __maybe_unused gpio_event_suspend(struct gpio_event *ip) { gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_SUSPEND); if (ip->info->power) ip->info->power(ip->info, 0); }
static int __init gpio_event_probe(struct platform_device *pdev) { int err; struct gpio_event *ip; struct gpio_event_platform_data *event_info; int dev_count = 1; int i; int registered = 0; event_info = pdev->dev.platform_data; if (event_info == NULL) { pr_err("gpio_event_probe: No pdata\n"); return -ENODEV; } if ((!event_info->name && !event_info->names[0]) || !event_info->info || !event_info->info_count) { pr_err("gpio_event_probe: Incomplete pdata\n"); return -ENODEV; } if (!event_info->name) while (event_info->names[dev_count]) dev_count++; ip = kzalloc(sizeof(*ip) + sizeof(ip->state[0]) * event_info->info_count + sizeof(*ip->input_devs) + sizeof(ip->input_devs->dev[0]) * dev_count, GFP_KERNEL); if (ip == NULL) { err = -ENOMEM; pr_err("gpio_event_probe: Failed to allocate private data\n"); goto err_kp_alloc_failed; } ip->input_devs = (void*)&ip->state[event_info->info_count]; platform_set_drvdata(pdev, ip); for (i = 0; i < dev_count; i++) { struct input_dev *input_dev = input_allocate_device(); if (input_dev == NULL) { err = -ENOMEM; pr_err("gpio_event_probe: " "Failed to allocate input device\n"); goto err_input_dev_alloc_failed; } input_set_drvdata(input_dev, ip); input_dev->name = event_info->name ? event_info->name : event_info->names[i]; input_dev->event = gpio_input_event; ip->input_devs->dev[i] = input_dev; } ip->input_devs->count = dev_count; ip->info = event_info; if (event_info->power) { #ifdef CONFIG_HAS_EARLYSUSPEND ip->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; ip->early_suspend.suspend = gpio_event_suspend; ip->early_suspend.resume = gpio_event_resume; register_early_suspend(&ip->early_suspend); #endif ip->info->power(ip->info, 1); } err = gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_INIT); if (err) goto err_call_all_func_failed; for (i = 0; i < dev_count; i++) { err = input_register_device(ip->input_devs->dev[i]); if (err) { pr_err("gpio_event_probe: Unable to register %s " "input device\n", ip->input_devs->dev[i]->name); goto err_input_register_device_failed; } registered++; } #if (defined(CONFIG_MACH_EUROPA) || defined(CONFIG_MACH_CALLISTO)|| defined(CONFIG_MACH_COOPER) || defined(CONFIG_MACH_BENI) || defined(CONFIG_MACH_TASS) || defined(CONFIG_MACH_LUCAS)) /* sys fs */ key_class = class_create(THIS_MODULE, "key"); if (IS_ERR(key_class)) pr_err("Failed to create class(key)!\n"); key_dev = device_create(key_class, NULL, 0, NULL, "key"); if (IS_ERR(key_dev)) pr_err("Failed to create device(key)!\n"); if (device_create_file(key_dev, &dev_attr_key) < 0) pr_err("Failed to create device file(%s)!\n", dev_attr_key.attr.name); /* sys fs */ #endif #ifndef CONFIG_MACH_LUCAS //for landscape UI (temporary patch) for (i = 0; i < registered; i++) { input_report_switch(ip->input_devs->dev[i], SW_LID, 1); input_sync(ip->input_devs->dev[i]); } #endif return 0; err_input_register_device_failed: gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_UNINIT); err_call_all_func_failed: if (event_info->power) { #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&ip->early_suspend); #endif ip->info->power(ip->info, 0); } for (i = 0; i < registered; i++) input_unregister_device(ip->input_devs->dev[i]); for (i = dev_count - 1; i >= registered; i--) { input_free_device(ip->input_devs->dev[i]); err_input_dev_alloc_failed: ; } kfree(ip); err_kp_alloc_failed: return err; }