int cyttsp4_mt_probe(struct device *dev) { struct cyttsp4_core_data *cd = dev_get_drvdata(dev); struct cyttsp4_mt_data *md = &cd->md; struct cyttsp4_platform_data *pdata = dev_get_platdata(dev); struct cyttsp4_mt_platform_data *mt_pdata; int rc = 0; dev_info(dev, "%s: \n", __func__); if (!pdata || !pdata->mt_pdata) { dev_err(dev, "%s: Missing platform data\n", __func__); rc = -ENODEV; goto error_no_pdata; } mt_pdata = pdata->mt_pdata; cyttsp4_init_function_ptrs(md); mutex_init(&md->mt_lock); md->prv_tch_type = CY_OBJ_STANDARD_FINGER; md->dev = dev; md->pdata = mt_pdata; #if defined(TSP_BOOSTER) mutex_init(&md->dvfs_lock); md->touch_pressed_num = 0; md->dvfs_lock_status = false; md->boost_level = DVFS_STAGE_DUAL; INIT_DELAYED_WORK(&md->work_dvfs_off, set_dvfs_off); INIT_DELAYED_WORK(&md->work_dvfs_chg, change_dvfs_lock); #endif /* 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) { dev_err(dev, "%s: Error, failed to allocate input device\n", __func__); rc = -ENOSYS; goto error_alloc_failed; } if (md->pdata->inp_dev_name) md->input->name = md->pdata->inp_dev_name; else md->input->name = CYTTSP4_MT_NAME; scnprintf(md->phys, sizeof(md->phys), "%s/input%d", dev_name(dev), cd->phys_num++); md->input->phys = md->phys; md->input->dev.parent = md->dev; md->input->open = cyttsp4_mt_open; md->input->close = cyttsp4_mt_close; input_set_drvdata(md->input, md); /* get sysinfo */ md->si = cyttsp4_request_sysinfo_(dev); if (md->si) { rc = cyttsp4_setup_input_device(dev); 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(dev, CY_ATTEN_STARTUP, CY_MODULE_MT, cyttsp4_setup_input_attention, 0); } return 0; error_init_input: input_free_device(md->input); error_alloc_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; }