static int diag_hsic_probe(struct platform_device *pdev) { int err = 0; pr_debug("diag: in %s\n", __func__); if (!driver->hsic_device_enabled) { diagmem_hsic_init(driver); INIT_WORK(&(driver->diag_read_hsic_work), diag_read_hsic_work_fn); driver->hsic_device_enabled = 1; } /* * The probe function was called after the usb was connected * on the legacy channel OR ODL is turned on. Communication over usb * mdm and hsic needs to be turned on. */ if (driver->usb_mdm_connected || (driver->logging_mode == MEMORY_DEVICE_MODE)) { /* The hsic (diag_bridge) platform device driver is enabled */ err = diag_bridge_open(&hsic_diag_bridge_ops); if (err) { pr_err("diag: could not open HSIC, err: %d\n", err); driver->hsic_device_opened = 0; return err; } pr_info("diag: opened HSIC channel\n"); driver->hsic_device_opened = 1; driver->hsic_ch = 1; driver->in_busy_hsic_read_on_device = 0; driver->in_busy_hsic_write = 0; if (driver->usb_mdm_connected) { /* Poll USB mdm channel to check for data */ queue_work(driver->diag_bridge_wq, &driver->diag_read_mdm_work); } /* Poll HSIC channel to check for data */ queue_work(driver->diag_bridge_wq, &driver->diag_read_hsic_work); } return err; }
static int diag_hsic_probe(struct platform_device *pdev) { int err = 0; DIAGFWD_INFO("diag: in %s\n", __func__); if (!driver->hsic_device_enabled) { diagmem_hsic_init(driver); INIT_WORK(&(driver->diag_read_hsic_work), diag_read_hsic_work_fn); driver->hsic_device_enabled = 1; } if (driver->usb_mdm_connected || (driver->logging_mode == MEMORY_DEVICE_MODE)) { err = diag_bridge_open(&hsic_diag_bridge_ops); if (err) { pr_err("diag: could not open HSIC, err: %d\n", err); driver->hsic_device_opened = 0; return err; } pr_info("diag: opened HSIC channel\n"); driver->hsic_device_opened = 1; driver->hsic_ch = 1; driver->in_busy_hsic_read_on_device = 0; driver->in_busy_hsic_write = 0; if (driver->usb_mdm_connected) { queue_work(driver->diag_bridge_wq, &driver->diag_read_mdm_work); } queue_work(driver->diag_bridge_wq, &driver->diag_read_hsic_work); } return err; }
static int diag_hsic_probe_data(int pdev_id) { int err = 0; int index = hsic_map[pdev_id].struct_idx; int b_index = hsic_map[pdev_id].bridge_idx; mutex_lock(&diag_bridge[index].bridge_mutex); if (!diag_hsic[index].hsic_inited) { spin_lock_init(&diag_hsic[index].hsic_spinlock); diag_hsic[index].num_hsic_buf_tbl_entries = 0; if (diag_hsic[index].hsic_buf_tbl == NULL) diag_hsic[index].hsic_buf_tbl = kzalloc(NUM_HSIC_BUF_TBL_ENTRIES * sizeof(struct diag_write_device), GFP_KERNEL); if (diag_hsic[index].hsic_buf_tbl == NULL) { mutex_unlock(&diag_bridge[index].bridge_mutex); return -ENOMEM; } diag_hsic[index].id = index; diag_hsic[index].count_hsic_pool = 0; diag_hsic[index].count_hsic_write_pool = 0; diag_hsic[index].itemsize_hsic = READ_HSIC_BUF_SIZE; diag_hsic[index].poolsize_hsic = N_MDM_WRITE; diag_hsic[index].itemsize_hsic_write = sizeof(struct diag_request); diag_hsic[index].poolsize_hsic_write = N_MDM_WRITE; diagmem_hsic_init(index); INIT_WORK(&(diag_hsic[index].diag_read_hsic_work), diag_read_hsic_work_fn); diag_hsic[index].hsic_data_requested = (driver->logging_mode == MEMORY_DEVICE_MODE) ? 0 : 1; diag_hsic[index].hsic_inited = 1; } /* * The probe function was called after the usb was connected * on the legacy channel OR ODL is turned on and hsic data is * requested. Communication over usb mdm and HSIC needs to be * turned on. */ if ((diag_bridge[index].usb_connected && (driver->logging_mode != MEMORY_DEVICE_MODE)) || ((driver->logging_mode == MEMORY_DEVICE_MODE) && diag_hsic[index].hsic_data_requested)) { if (diag_hsic[index].hsic_device_opened) { /* should not happen. close it before re-opening */ pr_warn("diag: HSIC channel already opened in probe\n"); diag_bridge_close(hsic_data_bridge_map[index]); } hsic_diag_bridge_ops[index].ctxt = (void *)(index); err = diag_bridge_open(b_index, &hsic_diag_bridge_ops[index]); if (err) { pr_err("diag: could not open HSIC, err: %d\n", err); diag_hsic[index].hsic_device_opened = 0; mutex_unlock(&diag_bridge[index].bridge_mutex); return err; } pr_info("diag: opened HSIC bridge, ch = %d\n", index); diag_hsic[index].hsic_device_opened = 1; diag_hsic[index].hsic_ch = 1; diag_hsic[index].in_busy_hsic_read_on_device = 0; diag_hsic[index].in_busy_hsic_write = 0; if (diag_bridge[index].usb_connected) { /* Poll USB mdm channel to check for data */ queue_work(diag_bridge[index].wq, &diag_bridge[index].diag_read_work); } /* Poll HSIC channel to check for data */ queue_work(diag_bridge[index].wq, &diag_hsic[index].diag_read_hsic_work); } /* The HSIC (diag_bridge) platform device driver is enabled */ diag_hsic[index].hsic_device_enabled = 1; mutex_unlock(&diag_bridge[index].bridge_mutex); return err; }
static int diag_hsic_probe(struct platform_device *pdev) { int err = 0; pr_debug("diag: in %s\n", __func__); mutex_lock(&diag_bridge[HSIC].bridge_mutex); if (!driver->hsic_inited) { spin_lock_init(&driver->hsic_spinlock); driver->num_hsic_buf_tbl_entries = 0; if (driver->hsic_buf_tbl == NULL) driver->hsic_buf_tbl = kzalloc(NUM_HSIC_BUF_TBL_ENTRIES * sizeof(struct diag_write_device), GFP_KERNEL); if (driver->hsic_buf_tbl == NULL) { mutex_unlock(&diag_bridge[HSIC].bridge_mutex); return -ENOMEM; } driver->count_hsic_pool = 0; driver->count_hsic_write_pool = 0; driver->itemsize_hsic = READ_HSIC_BUF_SIZE; driver->poolsize_hsic = N_MDM_WRITE; driver->itemsize_hsic_write = sizeof(struct diag_request); driver->poolsize_hsic_write = N_MDM_WRITE; diagmem_hsic_init(driver); INIT_WORK(&(driver->diag_read_hsic_work), diag_read_hsic_work_fn); driver->hsic_inited = 1; } if (diag_bridge[HSIC].usb_connected || (driver->logging_mode == MEMORY_DEVICE_MODE)) { if (driver->hsic_device_opened) { pr_warn("diag: HSIC channel already opened in probe\n"); diag_bridge_close(); } err = diag_bridge_open(&hsic_diag_bridge_ops); if (err) { pr_err("diag: could not open HSIC, err: %d\n", err); driver->hsic_device_opened = 0; mutex_unlock(&diag_bridge[HSIC].bridge_mutex); return err; } pr_info("diag: opened HSIC channel\n"); driver->hsic_device_opened = 1; driver->hsic_ch = 1; driver->in_busy_hsic_read_on_device = 0; driver->in_busy_hsic_write = 0; if (diag_bridge[HSIC].usb_connected) { queue_work(diag_bridge[HSIC].wq, &diag_bridge[HSIC].diag_read_work); } queue_work(diag_bridge[HSIC].wq, &driver->diag_read_hsic_work); } driver->hsic_device_enabled = 1; mutex_unlock(&diag_bridge[HSIC].bridge_mutex); return err; }
static int diag_hsic_probe(struct platform_device *pdev) { int err = 0; /* pdev->Id will indicate which HSIC is working. 0 stands for HSIC * or CP1 1 indicates HS-USB or CP2 */ pr_debug("diag: in %s, ch = %d\n", __func__, pdev->id); mutex_lock(&diag_bridge[pdev->id].bridge_mutex); if (!diag_hsic[pdev->id].hsic_inited) { spin_lock_init(&diag_hsic[pdev->id].hsic_spinlock); diag_hsic[pdev->id].num_hsic_buf_tbl_entries = 0; if (diag_hsic[pdev->id].hsic_buf_tbl == NULL) diag_hsic[pdev->id].hsic_buf_tbl = kzalloc(NUM_HSIC_BUF_TBL_ENTRIES * sizeof(struct diag_write_device), GFP_KERNEL); if (diag_hsic[pdev->id].hsic_buf_tbl == NULL) { mutex_unlock(&diag_bridge[pdev->id].bridge_mutex); return -ENOMEM; } diag_hsic[pdev->id].id = pdev->id; diag_hsic[pdev->id].count_hsic_pool = 0; diag_hsic[pdev->id].count_hsic_write_pool = 0; diag_hsic[pdev->id].itemsize_hsic = READ_HSIC_BUF_SIZE; diag_hsic[pdev->id].poolsize_hsic = N_MDM_WRITE; diag_hsic[pdev->id].itemsize_hsic_write = sizeof(struct diag_request); diag_hsic[pdev->id].poolsize_hsic_write = N_MDM_WRITE; diagmem_hsic_init(pdev->id); INIT_WORK(&(diag_hsic[pdev->id].diag_read_hsic_work), diag_read_hsic_work_fn); diag_hsic[pdev->id].hsic_inited = 1; } /* * The probe function was called after the usb was connected * on the legacy channel OR ODL is turned on. Communication over usb * mdm and HSIC needs to be turned on. */ if (diag_bridge[pdev->id].usb_connected || (driver->logging_mode == MEMORY_DEVICE_MODE)) { if (diag_hsic[pdev->id].hsic_device_opened) { /* should not happen. close it before re-opening */ pr_warn("diag: HSIC channel already opened in probe\n"); diag_bridge_close(pdev->id); } hsic_diag_bridge_ops[pdev->id].ctxt = (void *)(pdev->id); err = diag_bridge_open(pdev->id, &hsic_diag_bridge_ops[pdev->id]); if (err) { pr_err("diag: could not open HSIC, err: %d\n", err); diag_hsic[pdev->id].hsic_device_opened = 0; mutex_unlock(&diag_bridge[pdev->id].bridge_mutex); return err; } pr_info("diag: opened HSIC bridge, ch = %d\n", pdev->id); diag_hsic[pdev->id].hsic_device_opened = 1; diag_hsic[pdev->id].hsic_ch = 1; diag_hsic[pdev->id].in_busy_hsic_read_on_device = 0; diag_hsic[pdev->id].in_busy_hsic_write = 0; if (diag_bridge[pdev->id].usb_connected) { /* Poll USB mdm channel to check for data */ queue_work(diag_bridge[pdev->id].wq, &diag_bridge[pdev->id].diag_read_work); } /* Poll HSIC channel to check for data */ queue_work(diag_bridge[pdev->id].wq, &diag_hsic[pdev->id].diag_read_hsic_work); } /* The HSIC (diag_bridge) platform device driver is enabled */ diag_hsic[pdev->id].hsic_device_enabled = 1; mutex_unlock(&diag_bridge[pdev->id].bridge_mutex); return err; }
static int diag_hsic_probe(struct platform_device *pdev) { int err = 0; pr_debug("diag: in %s\n", __func__); if (!driver->hsic_device_enabled) { driver->read_len_mdm = 0; if (driver->usb_buf_mdm_out == NULL) driver->usb_buf_mdm_out = kzalloc(USB_MAX_OUT_BUF, GFP_KERNEL); if (driver->usb_buf_mdm_out == NULL) goto err; if (driver->usb_read_mdm_ptr == NULL) driver->usb_read_mdm_ptr = kzalloc( sizeof(struct diag_request), GFP_KERNEL); if (driver->usb_read_mdm_ptr == NULL) goto err; #ifdef CONFIG_DIAG_OVER_USB INIT_WORK(&(driver->diag_read_mdm_work), diag_read_mdm_work_fn); #endif diagmem_hsic_init(driver); INIT_WORK(&(driver->diag_read_hsic_work), diag_read_hsic_work_fn); driver->hsic_device_enabled = 1; } /* * The probe function was called after the usb was connected * on the legacy channel OR ODL is turned on. Communication over usb * mdm and hsic needs to be turned on. */ if (driver->usb_mdm_connected || (driver->logging_mode == MEMORY_DEVICE_MODE)) { /* The hsic (diag_bridge) platform device driver is enabled */ err = diag_bridge_open(&hsic_diag_bridge_ops); if (err) { pr_err("diag: could not open HSIC, err: %d\n", err); driver->hsic_device_opened = 0; return err; } pr_info("diag: opened HSIC channel\n"); driver->hsic_device_opened = 1; driver->hsic_ch = 1; driver->in_busy_hsic_read_on_device = 0; driver->in_busy_hsic_write = 0; if (driver->usb_mdm_connected) { /* Poll USB mdm channel to check for data */ queue_work(driver->diag_hsic_wq, &driver->diag_read_mdm_work); } /* Poll HSIC channel to check for data */ queue_work(driver->diag_hsic_wq, &driver->diag_read_hsic_work); } return err; err: pr_err("DIAG could not initialize buf for HSIC\n"); kfree(driver->usb_buf_mdm_out); kfree(driver->usb_read_mdm_ptr); if (driver->diag_hsic_wq) destroy_workqueue(driver->diag_hsic_wq); return -ENOMEM; }