int diag_mux_register(int proc, int ctx, struct diag_mux_ops *ops) { int err = 0; if (!ops) return -EINVAL; if (proc < 0 || proc >= NUM_MUX_PROC) return 0; /* Register with USB logger */ usb_logger.ops[proc] = ops; err = diag_usb_register(proc, ctx, ops); if (err) { pr_err("diag: MUX: unable to register usb operations for proc: %d, err: %d\n", proc, err); return err; } md_logger.ops[proc] = ops; err = diag_md_register(proc, ctx, ops); if (err) { pr_err("diag: MUX: unable to register md operations for proc: %d, err: %d\n", proc, err); return err; } #ifdef CONFIG_LGE_DM_APP #ifndef CONFIG_DIAGFWD_BRIDGE_CODE lge_dm_tty->id = DIAG_MUX_LOCAL; #else lge_dm_tty->id = DIAG_MUX_MDM; #endif lge_dm_tty->ctx = ctx; lge_dm_tty->ops = ops; #endif return 0; }
void diagfwd_init(void) { diag_debug_buf_idx = 0; spin_lock_init(&diagchar_smd_lock); spin_lock_init(&diagchar_smd_qdsp_lock); if (driver->usb_buf_out == NULL && (driver->usb_buf_out = kzalloc(USB_MAX_OUT_BUF, GFP_KERNEL)) == NULL) goto err; if (driver->hdlc_buf == NULL && (driver->hdlc_buf = kzalloc(HDLC_MAX, GFP_KERNEL)) == NULL) goto err; if (driver->msg_masks == NULL && (driver->msg_masks = kzalloc(MSG_MASK_SIZE, GFP_KERNEL)) == NULL) goto err; if (driver->log_masks == NULL && (driver->log_masks = kzalloc(LOG_MASK_SIZE, GFP_KERNEL)) == NULL) goto err; if (driver->event_masks == NULL && (driver->event_masks = kzalloc(EVENT_MASK_SIZE, GFP_KERNEL)) == NULL) goto err; if (driver->client_map == NULL && (driver->client_map = kzalloc ((driver->num_clients) * 4, GFP_KERNEL)) == NULL) goto err; 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; if (driver->data_ready == NULL && (driver->data_ready = kzalloc(driver->num_clients, GFP_KERNEL)) == NULL) goto err; if (driver->table == NULL && (driver->table = kzalloc(REG_TABLE_SIZE* sizeof(struct diag_master_table), GFP_KERNEL)) == NULL) goto err; if (driver->usb_write_ptr == NULL) driver->usb_write_ptr = kzalloc( sizeof(struct diag_request), GFP_KERNEL); if (driver->usb_write_ptr == NULL) goto err; if (driver->usb_write_ptr_qdsp == NULL) driver->usb_write_ptr_qdsp = kzalloc( sizeof(struct diag_request), GFP_KERNEL); if (driver->usb_write_ptr_qdsp == NULL) goto err; 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; if (driver->pkt_buf == NULL && (driver->pkt_buf = kzalloc(PKT_SIZE, GFP_KERNEL)) == NULL) goto err; driver->diag_wq = create_singlethread_workqueue("diag_wq"); INIT_WORK(&(driver->diag_read_work), diag_read_work_fn); diag_usb_register(&diagfwdops); platform_driver_register(&msm_smd_ch1_driver); return; err: printk(KERN_INFO "\n Could not initialize diag buffers\n"); kfree(driver->usb_buf_out); kfree(driver->hdlc_buf); kfree(driver->msg_masks); kfree(driver->log_masks); kfree(driver->event_masks); kfree(driver->client_map); kfree(driver->buf_tbl); kfree(driver->data_ready); kfree(driver->table); kfree(driver->pkt_buf); kfree(driver->usb_write_ptr); kfree(driver->usb_write_ptr_qdsp); kfree(driver->usb_read_ptr); }
void diagfwd_init(void) { diag_debug_buf_idx = 0; driver->read_len_legacy = 0; if (driver->buf_in_1 == NULL) driver->buf_in_1 = kzalloc(IN_BUF_SIZE, GFP_KERNEL); if (driver->buf_in_1 == NULL) goto err; if (driver->buf_in_2 == NULL) driver->buf_in_2 = kzalloc(IN_BUF_SIZE, GFP_KERNEL); if (driver->buf_in_2 == NULL) goto err; if (driver->buf_in_qdsp_1 == NULL) driver->buf_in_qdsp_1 = kzalloc(IN_BUF_SIZE, GFP_KERNEL); if (driver->buf_in_qdsp_1 == NULL) goto err; if (driver->buf_in_qdsp_2 == NULL) driver->buf_in_qdsp_2 = kzalloc(IN_BUF_SIZE, GFP_KERNEL); if (driver->buf_in_qdsp_2 == NULL) goto err; if (driver->usb_buf_out == NULL && (driver->usb_buf_out = kzalloc(USB_MAX_OUT_BUF, GFP_KERNEL)) == NULL) goto err; if (driver->hdlc_buf == NULL && (driver->hdlc_buf = kzalloc(HDLC_MAX, GFP_KERNEL)) == NULL) goto err; if (driver->msg_masks == NULL && (driver->msg_masks = kzalloc(MSG_MASK_SIZE, GFP_KERNEL)) == NULL) goto err; if (driver->log_masks == NULL && (driver->log_masks = kzalloc(LOG_MASK_SIZE, GFP_KERNEL)) == NULL) goto err; driver->log_masks_length = 8*MAX_EQUIP_ID; if (driver->event_masks == NULL && (driver->event_masks = kzalloc(EVENT_MASK_SIZE, GFP_KERNEL)) == NULL) goto err; if (driver->client_map == NULL && (driver->client_map = kzalloc ((driver->num_clients) * sizeof(struct diag_client_map), GFP_KERNEL)) == NULL) goto err; 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; if (driver->data_ready == NULL && (driver->data_ready = kzalloc(driver->num_clients * sizeof(struct diag_client_map), GFP_KERNEL)) == NULL) goto err; if (driver->table == NULL && (driver->table = kzalloc(diag_max_registration* sizeof(struct diag_master_table), GFP_KERNEL)) == NULL) goto err; if (driver->write_ptr_1 == NULL) driver->write_ptr_1 = kzalloc( sizeof(struct diag_request), GFP_KERNEL); if (driver->write_ptr_1 == NULL) goto err; if (driver->write_ptr_2 == NULL) driver->write_ptr_2 = kzalloc( sizeof(struct diag_request), GFP_KERNEL); if (driver->write_ptr_2 == NULL) goto err; if (driver->write_ptr_qdsp_1 == NULL) driver->write_ptr_qdsp_1 = kzalloc( sizeof(struct diag_request), GFP_KERNEL); if (driver->write_ptr_qdsp_1 == NULL) goto err; if (driver->write_ptr_qdsp_2 == NULL) driver->write_ptr_qdsp_2 = kzalloc( sizeof(struct diag_request), GFP_KERNEL); if (driver->write_ptr_qdsp_2 == NULL) goto err; 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; if (driver->pkt_buf == NULL && (driver->pkt_buf = kzalloc(PKT_SIZE, GFP_KERNEL)) == NULL) goto err; if (driver->apps_rsp_buf == NULL) driver->apps_rsp_buf = kzalloc(150, GFP_KERNEL); if (driver->apps_rsp_buf == NULL) goto err; 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); #ifdef CONFIG_SH_USB_CUST diag_usb_register(&diagfwdops); driver->legacy_ch = 0; #else /* CONFIG_SH_USB_CUST */ 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 /* CONFIG_SH_USB_CUST */ #ifdef CONFIG_DIAG_SDIO_PIPE if (machine_is_msm8x60_charm_surf() || machine_is_msm8x60_charm_ffa()) diagfwd_sdio_init(); #endif #endif platform_driver_register(&msm_smd_ch1_driver); return; err: printk(KERN_INFO "\n Could not initialize diag buffers\n"); kfree(driver->buf_in_1); kfree(driver->buf_in_2); kfree(driver->buf_in_qdsp_1); kfree(driver->buf_in_qdsp_2); kfree(driver->usb_buf_out); kfree(driver->hdlc_buf); kfree(driver->msg_masks); kfree(driver->log_masks); kfree(driver->event_masks); kfree(driver->client_map); kfree(driver->buf_tbl); kfree(driver->data_ready); kfree(driver->table); kfree(driver->pkt_buf); kfree(driver->write_ptr_1); kfree(driver->write_ptr_2); kfree(driver->write_ptr_qdsp_1); kfree(driver->write_ptr_qdsp_2); kfree(driver->usb_read_ptr); kfree(driver->apps_rsp_buf); #ifndef CONFIG_SH_USB_CUST if (driver->diag_wq) destroy_workqueue(driver->diag_wq); #endif /* CONFIG_SH_USB_CUST */ }
void diagfwd_init(void) { diag_debug_buf_idx = 0; if (driver->usb_buf_out == NULL && (driver->usb_buf_out = kzalloc(USB_MAX_OUT_BUF, GFP_KERNEL)) == NULL) goto err; if (driver->hdlc_buf == NULL && (driver->hdlc_buf = kzalloc(HDLC_MAX, GFP_KERNEL)) == NULL) goto err; if (driver->msg_masks == NULL && (driver->msg_masks = kzalloc(MSG_MASK_SIZE, GFP_KERNEL)) == NULL) goto err; if (driver->log_masks == NULL && (driver->log_masks = kzalloc(LOG_MASK_SIZE, GFP_KERNEL)) == NULL) goto err; if (driver->event_masks == NULL && (driver->event_masks = kzalloc(EVENT_MASK_SIZE, GFP_KERNEL)) == NULL) goto err; if (driver->client_map == NULL && (driver->client_map = kzalloc ((driver->num_clients) * sizeof(struct diag_client_map), GFP_KERNEL)) == NULL) goto err; if (driver->mdmclient_map == NULL && (driver->mdmclient_map = kzalloc ((driver->num_mdmclients) * sizeof(struct diag_client_map), GFP_KERNEL)) == NULL) goto err; 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; if (driver->mdmbuf_tbl == NULL) driver->mdmbuf_tbl = kzalloc(buf_tbl_size * sizeof(struct diag_write_device), GFP_KERNEL); if (driver->mdmbuf_tbl == NULL) goto err; if (driver->data_ready == NULL && (driver->data_ready = kzalloc(driver->num_clients * sizeof(struct diag_client_map), GFP_KERNEL)) == NULL) goto err; if (driver->mdmdata_ready == NULL && (driver->mdmdata_ready = kzalloc(driver->num_mdmclients * sizeof(struct diag_client_map), GFP_KERNEL)) == NULL) goto err; if (driver->table == NULL && (driver->table = kzalloc(diag_max_registration* sizeof(struct diag_master_table), GFP_KERNEL)) == NULL) goto err; if (driver->usb_write_ptr_1 == NULL) driver->usb_write_ptr_1 = kzalloc( sizeof(struct diag_request), GFP_KERNEL); if (driver->usb_write_ptr_1 == NULL) goto err; if (driver->usb_write_ptr_2 == NULL) driver->usb_write_ptr_2 = kzalloc( sizeof(struct diag_request), GFP_KERNEL); if (driver->usb_write_ptr_2 == NULL) goto err; if (driver->usb_write_ptr_qdsp_1 == NULL) driver->usb_write_ptr_qdsp_1 = kzalloc( sizeof(struct diag_request), GFP_KERNEL); if (driver->usb_write_ptr_qdsp_1 == NULL) goto err; if (driver->usb_write_ptr_qdsp_2 == NULL) driver->usb_write_ptr_qdsp_2 = kzalloc( sizeof(struct diag_request), GFP_KERNEL); if (driver->usb_write_ptr_qdsp_2 == NULL) goto err; if (driver->usb_write_ptr_mdm_1 == NULL) driver->usb_write_ptr_mdm_1 = kzalloc( sizeof(struct diag_request), GFP_KERNEL); if (driver->usb_write_ptr_mdm_1 == NULL) goto err; if (driver->usb_write_ptr_mdm_2 == NULL) driver->usb_write_ptr_mdm_2 = kzalloc( sizeof(struct diag_request), GFP_KERNEL); if (driver->usb_write_ptr_mdm_2 == NULL) goto err; 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; if (driver->pkt_buf == NULL && (driver->pkt_buf = kzalloc(PKT_SIZE, GFP_KERNEL)) == NULL) goto err; driver->diag_wq = create_singlethread_workqueue("diag_wq"); INIT_WORK(&(driver->diag_read_work), diag_read_work_fn); platform_driver_register(&msm_smd_ch1_driver); mutex_init(&driver->smd_lock); driver->init_done = 1; diag_usb_register(&diagfwdops); /* for MDM9k */ sdio_diag_init(); return; err: printk(KERN_INFO "\n Could not initialize diag buffers\n"); kfree(driver->usb_buf_out); kfree(driver->hdlc_buf); kfree(driver->msg_masks); kfree(driver->log_masks); kfree(driver->event_masks); kfree(driver->client_map); kfree(driver->mdmclient_map); kfree(driver->buf_tbl); kfree(driver->mdmbuf_tbl); kfree(driver->data_ready); kfree(driver->mdmdata_ready); kfree(driver->table); kfree(driver->pkt_buf); kfree(driver->usb_write_ptr_1); kfree(driver->usb_write_ptr_2); kfree(driver->usb_write_ptr_qdsp_1); kfree(driver->usb_write_ptr_qdsp_2); kfree(driver->usb_write_ptr_mdm_1); kfree(driver->usb_write_ptr_mdm_2); kfree(driver->usb_read_ptr); }