static int cyttsp4_setup_input_attention(struct cyttsp4_device *ttsp) { struct device *dev = &ttsp->dev; struct cyttsp4_proximity_data *pd = dev_get_drvdata(dev); int rc; tp_log_debug("%s\n", __func__); pd->si = cyttsp4_request_sysinfo(ttsp); if (!pd->si) return -EINVAL; rc = cyttsp4_setup_input_device_and_sysfs(ttsp); cyttsp4_unsubscribe_attention(ttsp, CY_ATTEN_STARTUP, cyttsp4_setup_input_attention, 0); return rc; }
static int cyttsp4_setup_input_attention(struct cyttsp4_device *ttsp) { struct device *dev = &ttsp->dev; struct cyttsp4_btn_data *bd = dev_get_drvdata(dev); int rc; dev_vdbg(dev, "%s\n", __func__); bd->si = cyttsp4_request_sysinfo(ttsp); if (!bd->si) return -1; rc = cyttsp4_setup_input_device(ttsp); cyttsp4_unsubscribe_attention(ttsp, CY_ATTEN_STARTUP, cyttsp4_setup_input_attention, 0); return rc; }
static int cyttsp4_proximity_probe(struct cyttsp4_device *ttsp) { struct cyttsp4_proximity_data *pd; struct device *dev = &ttsp->dev; struct cyttsp4_proximity_platform_data *pdata = dev_get_platdata(dev); int rc = 0; tp_log_info("%s\n", __func__); tp_log_debug("%s: debug on\n", __func__); tp_log_debug("%s: verbose debug on\n", __func__); if (pdata == NULL) { tp_log_err("%s: Missing platform data\n", __func__); rc = -ENODEV; goto error_no_pdata; } pd = kzalloc(sizeof(*pd), GFP_KERNEL); if (pd == NULL) { tp_log_err("%s: Error, kzalloc\n", __func__); rc = -ENOMEM; goto error_alloc_data_failed; } mutex_init(&pd->report_lock); mutex_init(&pd->sysfs_lock); pd->ttsp = ttsp; pd->pdata = pdata; dev_set_drvdata(dev, pd); /* Create the input device and register it. */ tp_log_debug("%s: Create the input device and register it\n", __func__); pd->input = input_allocate_device(); if (pd->input == NULL) { tp_log_err("%s: Error, failed to allocate input device\n", __func__); rc = -ENOSYS; goto error_alloc_failed; } pd->input->name = ttsp->name; scnprintf(pd->phys, sizeof(pd->phys) - 1, "%s", dev_name(dev)); pd->input->phys = pd->phys; pd->input->dev.parent = &pd->ttsp->dev; input_set_drvdata(pd->input, pd); pm_runtime_enable(dev); /* get sysinfo */ pd->si = cyttsp4_request_sysinfo(ttsp); if (pd->si) { rc = cyttsp4_setup_input_device_and_sysfs(ttsp); if (rc) goto error_init_input; } else { tp_log_err("%s: Fail get sysinfo pointer from core \n", __func__); cyttsp4_subscribe_attention(ttsp, CY_ATTEN_STARTUP, cyttsp4_setup_input_attention, 0); } tp_log_debug("%s: ok\n", __func__); return 0; error_init_input: pm_runtime_suspend(dev); pm_runtime_disable(dev); input_free_device(pd->input); error_alloc_failed: dev_set_drvdata(dev, NULL); kfree(pd); error_alloc_data_failed: error_no_pdata: tp_log_err("%s failed.\n", __func__); return rc; }
static int cyttsp4_debug_probe(struct cyttsp4_device *ttsp) { struct device *dev = &ttsp->dev; struct cyttsp4_debug_data *dd; struct cyttsp4_debug_platform_data *pdata = dev_get_platdata(dev); int rc; dev_info(dev, "%s: startup\n", __func__); dev_dbg(dev, "%s: debug on\n", __func__); dev_vdbg(dev, "%s: verbose debug on\n", __func__); /* get context and debug print buffers */ dd = kzalloc(sizeof(*dd), GFP_KERNEL); if (dd == NULL) { dev_err(dev, "%s: Error, kzalloc\n", __func__); rc = -ENOMEM; goto cyttsp4_debug_probe_alloc_failed; } rc = device_create_file(dev, &dev_attr_int_count); if (rc) { dev_err(dev, "%s: Error, could not create int_count\n", __func__); goto cyttsp4_debug_probe_create_int_count_failed; } rc = device_create_file(dev, &dev_attr_formated_output); if (rc) { dev_err(dev, "%s: Error, could not create formated_output\n", __func__); goto cyttsp4_debug_probe_create_formated_failed; } mutex_init(&dd->sysfs_lock); dd->ttsp = ttsp; dd->pdata = pdata; dev_set_drvdata(dev, dd); pm_runtime_enable(dev); dd->si = cyttsp4_request_sysinfo(ttsp); if (dd->si == NULL) { dev_err(dev, "%s: Fail get sysinfo pointer from core\n", __func__); rc = -ENODEV; goto cyttsp4_debug_probe_sysinfo_failed; } rc = cyttsp4_subscribe_attention(ttsp, CY_ATTEN_IRQ, cyttsp4_debug_attention, CY_MODE_OPERATIONAL); if (rc < 0) { dev_err(dev, "%s: Error, could not subscribe attention cb\n", __func__); goto cyttsp4_debug_probe_subscribe_failed; } return 0; cyttsp4_debug_probe_subscribe_failed: cyttsp4_debug_probe_sysinfo_failed: pm_runtime_disable(dev); dev_set_drvdata(dev, NULL); device_remove_file(dev, &dev_attr_formated_output); cyttsp4_debug_probe_create_formated_failed: device_remove_file(dev, &dev_attr_int_count); cyttsp4_debug_probe_create_int_count_failed: kfree(dd); cyttsp4_debug_probe_alloc_failed: dev_err(dev, "%s failed.\n", __func__); return rc; }
static int cyttsp4_btn_probe(struct cyttsp4_device *ttsp) { struct cyttsp4_btn_data *bd; struct device *dev = &ttsp->dev; struct cyttsp4_btn_platform_data *pdata = dev_get_platdata(dev); int rc = 0; dev_info(dev, "%s\n", __func__); dev_dbg(dev, "%s: debug on\n", __func__); dev_vdbg(dev, "%s: verbose debug on\n", __func__); /*Increase the judgment conditions*/ if (pdata == NULL) { dev_err(dev, "%s: Missing platform data\n", __func__); rc = -ENODEV; goto error_no_pdata; } bd = kzalloc(sizeof(*bd), GFP_KERNEL); if (bd == NULL) { dev_err(dev, "%s: Error, kzalloc\n", __func__); rc = -ENOMEM; goto error_alloc_data_failed; } mutex_init(&bd->report_lock); bd->ttsp = ttsp; bd->pdata = pdata; dev_set_drvdata(dev, bd); /* Create the input device and register it. */ dev_vdbg(dev, "%s: Create the input device and register it\n", __func__); bd->input = input_allocate_device(); if (bd->input == NULL) { dev_err(dev, "%s: Error, failed to allocate input device\n", __func__); rc = -ENOSYS; goto error_alloc_failed; } bd->input->name = ttsp->name; scnprintf(bd->phys, sizeof(bd->phys)-1, "%s", dev_name(dev)); bd->input->phys = bd->phys; bd->input->dev.parent = &bd->ttsp->dev; bd->input->open = cyttsp4_btn_open; bd->input->close = cyttsp4_btn_close; input_set_drvdata(bd->input, bd); pm_runtime_enable(dev); /* get sysinfo */ bd->si = cyttsp4_request_sysinfo(ttsp); if (bd->si) { rc = cyttsp4_setup_input_device(ttsp); if (rc) goto error_init_input; } else { dev_err(dev, "%s: Fail get sysinfo pointer from core p=%p\n", __func__, bd->si); cyttsp4_subscribe_attention(ttsp, CY_ATTEN_STARTUP, cyttsp4_setup_input_attention, 0); } #ifdef CONFIG_HAS_EARLYSUSPEND bd->es.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; bd->es.suspend = cyttsp4_btn_early_suspend; bd->es.resume = cyttsp4_btn_late_resume; register_early_suspend(&bd->es); #endif dev_dbg(dev, "%s: ok\n", __func__); return 0; error_init_input: pm_runtime_suspend(dev); pm_runtime_disable(dev); input_free_device(bd->input); error_alloc_failed: dev_set_drvdata(dev, NULL); kfree(bd); error_alloc_data_failed: error_no_pdata: dev_err(dev, "%s failed.\n", __func__); return rc; }
static int cyttsp4_mt_probe(struct cyttsp4_device *ttsp) { struct device *dev = &ttsp->dev; struct cyttsp4_mt_data *md; struct cyttsp4_mt_platform_data *pdata = dev_get_platdata(dev); int rc = 0; dev_dbg(dev, "%s\n", __func__); dev_dbg(dev, "%s: debug on\n", __func__); dev_vdbg(dev, "%s: verbose debug on\n", __func__); if (pdata == NULL) { dev_err(dev, "%s: Missing platform data\n", __func__); rc = -ENODEV; goto error_no_pdata; } md = kzalloc(sizeof(*md), GFP_KERNEL); if (md == NULL) { dev_err(dev, "%s: Error, kzalloc\n", __func__); rc = -ENOMEM; goto error_alloc_data_failed; } cyttsp4_init_function_ptrs(md); mutex_init(&md->report_lock); md->prv_tch_type = CY_OBJ_STANDARD_FINGER; md->ttsp = ttsp; md->pdata = pdata; dev_set_drvdata(dev, md); /* Create the input device and register it. */ dev_vdbg(dev, "%s: Create the input device and register it\n", __func__); md->input = input_allocate_device(); if (md->input == NULL) { dev_err(dev, "%s: Error, failed to allocate input device\n", __func__); rc = -ENOSYS; goto error_alloc_failed; } md->input->name = ttsp->name; scnprintf(md->phys, sizeof(md->phys)-1, "%s", dev_name(dev)); md->input->phys = md->phys; md->input->dev.parent = &md->ttsp->dev; md->input->open = cyttsp4_mt_open; md->input->close = cyttsp4_mt_close; input_set_drvdata(md->input, md); pm_runtime_enable(dev); /* get sysinfo */ md->si = cyttsp4_request_sysinfo(ttsp); if (md->si) { rc = cyttsp4_setup_input_device(ttsp); if (rc) goto error_init_input; } else { dev_err(dev, "%s: Fail get sysinfo pointer from core p=%p\n", __func__, md->si); cyttsp4_subscribe_attention(ttsp, CY_ATTEN_STARTUP, cyttsp4_setup_input_attention, 0); } //#ifdef CONFIG_HAS_EARLYSUSPEND cyttsp4_setup_early_suspend(md); //#endif dev_dbg(dev, "%s: OK\n", __func__); return 0; error_init_input: pm_runtime_suspend(dev); pm_runtime_disable(dev); input_free_device(md->input); error_alloc_failed: dev_set_drvdata(dev, NULL); kfree(md); error_alloc_data_failed: error_no_pdata: dev_err(dev, "%s failed.\n", __func__); return rc; }