void diagfwd_cntl_init(void) { int success; int i; reg_dirty = 0; driver->polling_reg_flag = 0; driver->log_on_demand_support = 1; driver->diag_cntl_wq = create_singlethread_workqueue("diag_cntl_wq"); for (i = 0; i < NUM_SMD_CONTROL_CHANNELS; i++) { success = diag_smd_constructor(&driver->smd_cntl[i], i, SMD_CNTL_TYPE); if (!success) goto err; } platform_driver_register(&msm_smd_ch1_cntl_driver); platform_driver_register(&diag_smd_lite_cntl_driver); return; err: pr_err("diag: Could not initialize diag buffers"); for (i = 0; i < NUM_SMD_CONTROL_CHANNELS; i++) diag_smd_destructor(&driver->smd_cntl[i]); if (driver->diag_cntl_wq) destroy_workqueue(driver->diag_cntl_wq); }
void diagfwd_init(void) { int success; int i; wrap_enabled = 0; wrap_count = 0; diag_debug_buf_idx = 0; driver->read_len_legacy = 0; driver->use_device_tree = has_device_tree(); mutex_init(&driver->diag_cntl_mutex); success = diag_smd_constructor(&driver->smd_data[MODEM_DATA], MODEM_DATA, SMD_DATA_TYPE); if (!success) goto err; success = diag_smd_constructor(&driver->smd_data[LPASS_DATA], LPASS_DATA, SMD_DATA_TYPE); if (!success) goto err; success = diag_smd_constructor(&driver->smd_data[WCNSS_DATA], WCNSS_DATA, SMD_DATA_TYPE); if (!success) goto err; if (driver->usb_buf_out == NULL && (driver->usb_buf_out = kzalloc(USB_MAX_OUT_BUF, GFP_KERNEL)) == NULL) goto err; kmemleak_not_leak(driver->usb_buf_out); if (driver->hdlc_buf == NULL && (driver->hdlc_buf = kzalloc(HDLC_MAX, GFP_KERNEL)) == NULL) goto err; kmemleak_not_leak(driver->hdlc_buf); if (driver->user_space_data == NULL) driver->user_space_data = kzalloc(USER_SPACE_DATA, GFP_KERNEL); if (driver->user_space_data == NULL) goto err; kmemleak_not_leak(driver->user_space_data); if (driver->client_map == NULL && (driver->client_map = kzalloc ((driver->num_clients) * sizeof(struct diag_client_map), GFP_KERNEL)) == NULL) goto err; kmemleak_not_leak(driver->client_map); if (driver->buf_tbl == NULL) driver->buf_tbl = kzalloc(buf_tbl_size * sizeof(struct diag_write_device), GFP_KERNEL); if (driver->buf_tbl == NULL) goto err; kmemleak_not_leak(driver->buf_tbl); if (driver->data_ready == NULL && (driver->data_ready = kzalloc(driver->num_clients * sizeof(int) , GFP_KERNEL)) == NULL) goto err; kmemleak_not_leak(driver->data_ready); if (driver->table == NULL && (driver->table = kzalloc(diag_max_reg* sizeof(struct diag_master_table), GFP_KERNEL)) == NULL) goto err; kmemleak_not_leak(driver->table); if (driver->usb_read_ptr == NULL) { driver->usb_read_ptr = kzalloc( sizeof(struct diag_request), GFP_KERNEL); if (driver->usb_read_ptr == NULL) goto err; kmemleak_not_leak(driver->usb_read_ptr); } if (driver->pkt_buf == NULL && (driver->pkt_buf = kzalloc(PKT_SIZE, GFP_KERNEL)) == NULL) goto err; kmemleak_not_leak(driver->pkt_buf); if (driver->apps_rsp_buf == NULL) { driver->apps_rsp_buf = kzalloc(APPS_BUF_SIZE, GFP_KERNEL); if (driver->apps_rsp_buf == NULL) goto err; kmemleak_not_leak(driver->apps_rsp_buf); } driver->diag_wq = create_singlethread_workqueue("diag_wq"); #ifdef CONFIG_DIAG_OVER_USB INIT_WORK(&(driver->diag_proc_hdlc_work), diag_process_hdlc_fn); INIT_WORK(&(driver->diag_read_work), diag_read_work_fn); driver->legacy_ch = usb_diag_open(DIAG_LEGACY, driver, diag_usb_legacy_notifier); if (IS_ERR(driver->legacy_ch)) { printk(KERN_ERR "Unable to open USB diag legacy channel\n"); goto err; } #endif platform_driver_register(&msm_smd_ch1_driver); platform_driver_register(&diag_smd_lite_driver); return; err: pr_err("diag: Could not initialize diag buffers"); for (i = 0; i < NUM_SMD_DATA_CHANNELS; i++) diag_smd_destructor(&driver->smd_data[i]); kfree(driver->buf_msg_mask_update); kfree(driver->buf_log_mask_update); kfree(driver->buf_event_mask_update); kfree(driver->usb_buf_out); kfree(driver->hdlc_buf); kfree(driver->client_map); kfree(driver->buf_tbl); kfree(driver->data_ready); kfree(driver->table); kfree(driver->pkt_buf); kfree(driver->usb_read_ptr); kfree(driver->apps_rsp_buf); kfree(driver->user_space_data); if (driver->diag_wq) destroy_workqueue(driver->diag_wq); }