static int diagchar_close(struct inode *inode, struct file *file) { int i = 0; struct diagchar_priv *diagpriv_data = file->private_data; if (!(file->private_data)) { pr_alert("diag: Invalid file pointer"); return -ENOMEM; } if (driver) { #ifdef CONFIG_DIAG_OVER_USB /* If the SD logging process exits, change logging to USB mode */ if (driver->logging_process_id == current->tgid && (driver->logging_mode != USB_MODE)) { driver->logging_mode = USB_MODE; diagfwd_connect(); } #endif /* DIAG over USB */ /* Delete the pkt response table entry for the exiting process */ for (i = 0; i < diag_max_registration; i++) if (driver->table[i].process_id == current->tgid) driver->table[i].process_id = 0; mutex_lock(&driver->diagchar_mutex); driver->ref_count--; /* On Client exit, try to destroy all 3 pools */ diagmem_exit(driver, POOL_TYPE_COPY); diagmem_exit(driver, POOL_TYPE_HDLC); diagmem_exit(driver, POOL_TYPE_WRITE_STRUCT); for (i = 0; i < driver->num_clients; i++) { if (NULL != diagpriv_data && diagpriv_data->pid == driver->client_map[i].pid) { driver->client_map[i].pid = 0; kfree(diagpriv_data); diagpriv_data = NULL; break; } } mutex_unlock(&driver->diagchar_mutex); return 0; } return -ENOMEM; }
static int diagcharmdm_close(struct inode *inode, struct file *file) { int i = 0; #if defined(CONFIG_MACH_MECHA) if (!sdio_diag_initialized) { DIAG_INFO("sdio diag isn't in embedded mode \n"); return 0; } #endif DIAG_INFO("%s:%s(parent:%s): tgid=%d\n", __func__, current->comm, current->parent->comm, current->tgid); if (driver) { mutex_lock(&driver->diagcharmdm_mutex); #if defined(CONFIG_ARCH_MSM8X60_LTE) driver->ref_count--; /* On Client exit, try to destroy all 3 pools */ diagmem_exit(driver, POOL_TYPE_COPY); diagmem_exit(driver, POOL_TYPE_HDLC); diagmem_exit(driver, POOL_TYPE_WRITE_STRUCT); #endif for (i = 0; i < driver->num_mdmclients; i++) if (driver->mdmclient_map[i].pid == current->tgid) { driver->mdmclient_map[i].pid = 0; break; } if (i < driver->num_mdmclients) DIAG_INFO("%s:#%d(%d) %s close\n", __func__, i, current->tgid, current->comm); else DIAG_WARNING("%s: nothing close\n", __func__); mutex_unlock(&driver->diagcharmdm_mutex); return 0; } return -ENOMEM; }
static void __exit diagchar_exit(void) { printk(KERN_INFO "diagchar exiting ..\n"); /* On Driver exit, send special pool type to ensure no memory leaks */ diagmem_exit(driver, POOL_TYPE_ALL); diagfwd_exit(); diagchar_cleanup(); printk(KERN_INFO "done diagchar exit\n"); }
void diagmem_free(struct diagchar_dev *driver, void *buf) { if (driver->diagpool != NULL && driver->count > 0) { mempool_free(buf, driver->diagpool); atomic_add(-1, (atomic_t *)&driver->count); } else printk(KERN_ALERT "\n Attempt to free up DIAG driver mempool" " memory which is already free"); diagmem_exit(driver); }
static void __exit diagchar_exit(void) { DIAG_INFO("diagchar exiting ..\n"); /* On Driver exit, send special pool type to ensure no memory leaks */ diagmem_exit(driver, POOL_TYPE_ALL); diagfwd_exit(); #if defined(CONFIG_ARCH_MSM8X60_LTE) diagfwd_sdio_exit(); #endif diagchar_cleanup(); DIAG_INFO("done diagchar exit\n"); }
static void __exit diagchar_exit(void) { printk(KERN_INFO "diagchar exiting ..\n"); /* On Driver exit, send special pool type to ensure no memory leaks */ diagmem_exit(driver, POOL_TYPE_ALL); diagfwd_exit(); if (chk_config_get_id() == AO8960_TOOLS_ID) diagfwd_cntl_exit(); diag_sdio_fn(EXIT); diagchar_cleanup(); printk(KERN_INFO "done diagchar exit\n"); }
static void diagchar_exit(void) { printk(KERN_INFO "diagchar exiting ..\n"); /* On Driver exit, send special pool type to ensure no memory leaks */ diagmem_exit(driver, POOL_TYPE_ALL); diagfwd_exit(); diagfwd_cntl_exit(); diag_sdio_fn(EXIT); diag_bridge_fn(EXIT); diag_debugfs_cleanup(); diagchar_cleanup(); printk(KERN_INFO "done diagchar exit\n"); }
static void __exit diagchar_exit(void) { printk(KERN_INFO "diagchar exiting ..\n"); /* On Driver exit, send special pool type to ensure no memory leaks */ diagmem_exit(driver, POOL_TYPE_ALL); diagfwd_exit(); #ifdef CONFIG_DIAG_SDIO_PIPE if (machine_is_msm8x60_charm_surf() || machine_is_msm8x60_charm_ffa()) diagfwd_sdio_exit(); #endif diagchar_cleanup(); printk(KERN_INFO "done diagchar exit\n"); }
static void __exit diagchar_exit(void) { printk(KERN_INFO "diagchar exiting ..\n"); /* On Driver exit, send special pool type to ensure no memory leaks */ diagmem_exit(driver, POOL_TYPE_ALL); diagfwd_exit(); #ifdef CONFIG_HUAWEI_FEATURE_PHUDIAG phudiag_exit(); #endif diagfwd_cntl_exit(); diag_sdio_fn(EXIT); diagchar_cleanup(); printk(KERN_INFO "done diagchar exit\n"); }
void diagmem_free(struct diagchar_dev *driver, void *buf, int pool_type) { if (pool_type == POOL_TYPE_COPY) { if (driver->diagpool != NULL && driver->count > 0) { mempool_free(buf, driver->diagpool); atomic_add(-1, (atomic_t *)&driver->count); } else printk(KERN_ALERT "\n Attempt to free up DIAG driver" "mempool memory which is already free %d", driver->count); } else if (pool_type == POOL_TYPE_HDLC) { if (driver->diag_hdlc_pool != NULL && driver->count_hdlc_pool > 0) { mempool_free(buf, driver->diag_hdlc_pool); atomic_add(-1, (atomic_t *)&driver->count_hdlc_pool); } else printk(KERN_ALERT "\n Attempt to free up DIAG driver " "HDLC mempool which is already free %d ", driver->count_hdlc_pool); } diagmem_exit(driver); }
void diagfwd_bridge_exit(void) { int i; pr_debug("diag: in %s\n", __func__); for (i = 0; i < MAX_HSIC_CH; i++) { if (diag_hsic[i].hsic_device_enabled) { diag_hsic_close(i); diag_hsic[i].hsic_device_enabled = 0; diag_bridge[i].enabled = 0; } diag_hsic[i].hsic_inited = 0; kfree(diag_hsic[i].hsic_buf_tbl); } diagmem_exit(driver, POOL_TYPE_ALL); if (driver->diag_smux_enabled) { driver->lcid = LCID_INVALID; kfree(driver->buf_in_smux); driver->diag_smux_enabled = 0; diag_bridge[SMUX].enabled = 0; } platform_driver_unregister(&msm_hsic_ch_driver); platform_driver_unregister(&msm_diagfwd_smux_driver); /* destroy USB MDM specific variables */ for (i = 0; i < MAX_BRIDGES; i++) { if (diag_bridge[i].enabled) { #ifdef CONFIG_DIAG_OVER_USB if (diag_bridge[i].usb_connected) usb_diag_free_req(diag_bridge[i].ch); usb_diag_close(diag_bridge[i].ch); #endif kfree(diag_bridge[i].usb_buf_out); kfree(diag_bridge[i].usb_read_ptr); destroy_workqueue(diag_bridge[i].wq); diag_bridge[i].enabled = 0; } } kfree(driver->write_ptr_mdm); }
void diagfwd_hsic_exit(void) { pr_debug("diag: in %s\n", __func__); if (driver->hsic_initialized) diag_hsic_close(); diagmem_exit(driver, POOL_TYPE_ALL); /* destroy USB MDM specific variables */ #ifdef CONFIG_DIAG_OVER_USB if (driver->usb_mdm_connected) usb_diag_free_req(driver->mdm_ch); #endif platform_driver_unregister(&msm_hsic_ch_driver); #ifdef CONFIG_DIAG_OVER_USB usb_diag_close(driver->mdm_ch); #endif kfree(driver->usb_buf_mdm_out); kfree(driver->hsic_buf_tbl); kfree(driver->usb_read_mdm_ptr); destroy_workqueue(driver->diag_hsic_wq); driver->hsic_device_enabled = 0; }
void diagmem_free(struct diagchar_dev *driver, void *buf, int pool_type) { int index; index = 0; if (pool_type == POOL_TYPE_COPY) { if (driver->diagpool != NULL && driver->count > 0) { mempool_free(buf, driver->diagpool); atomic_add(-1, (atomic_t *)&driver->count); } else pr_err("diag: Attempt to free up DIAG driver mempool memory which is already free %d", driver->count); } else if (pool_type == POOL_TYPE_HDLC) { if (driver->diag_hdlc_pool != NULL && driver->count_hdlc_pool > 0) { mempool_free(buf, driver->diag_hdlc_pool); atomic_add(-1, (atomic_t *)&driver->count_hdlc_pool); } else pr_err("diag: Attempt to free up DIAG driver HDLC mempool which is already free %d ", driver->count_hdlc_pool); } else if (pool_type == POOL_TYPE_USER) { if (driver->diag_user_pool != NULL && driver->count_user_pool > 0) { mempool_free(buf, driver->diag_user_pool); atomic_add(-1, (atomic_t *)&driver->count_user_pool); } else { pr_err("diag: Attempt to free up DIAG driver USER mempool which is already free %d ", driver->count_user_pool); } } else if (pool_type == POOL_TYPE_WRITE_STRUCT) { if (driver->diag_write_struct_pool != NULL && driver->count_write_struct_pool > 0) { mempool_free(buf, driver->diag_write_struct_pool); atomic_add(-1, (atomic_t *)&driver->count_write_struct_pool); } else pr_err("diag: Attempt to free up DIAG driver USB structure mempool which is already free %d ", driver->count_write_struct_pool); #ifdef CONFIG_DIAGFWD_BRIDGE_CODE } else if (pool_type == POOL_TYPE_HSIC || pool_type == POOL_TYPE_HSIC_2) { index = pool_type - POOL_TYPE_HSIC; if (diag_hsic[index].diag_hsic_pool != NULL && diag_hsic[index].count_hsic_pool > 0) { mempool_free(buf, diag_hsic[index].diag_hsic_pool); atomic_add(-1, (atomic_t *) &diag_hsic[index].count_hsic_pool); } else pr_err("diag: Attempt to free up DIAG driver HSIC mempool which is already free %d, ch = %d", diag_hsic[index].count_hsic_pool, index); } else if (pool_type == POOL_TYPE_HSIC_WRITE || pool_type == POOL_TYPE_HSIC_2_WRITE) { index = pool_type - POOL_TYPE_HSIC_WRITE; if (diag_hsic[index].diag_hsic_write_pool != NULL && diag_hsic[index].count_hsic_write_pool > 0) { mempool_free(buf, diag_hsic[index].diag_hsic_write_pool); atomic_add(-1, (atomic_t *) &diag_hsic[index].count_hsic_write_pool); } else pr_err("diag: Attempt to free up DIAG driver HSIC USB structure mempool which is already free %d, ch = %d", driver->count_write_struct_pool, index); #endif } else { pr_err("diag: In %s, unknown pool type: %d\n", __func__, pool_type); } diagmem_exit(driver, pool_type); }
static int diagchar_close(struct inode *inode, struct file *file) { int i = 0; struct diagchar_priv *diagpriv_data = file->private_data; if (!(file->private_data)) { pr_alert("diag: Invalid file pointer"); return -ENOMEM; } /* clean up any DCI registrations for this client * This will specially help in case of ungraceful exit of any DCI client * This call will remove any pending registrations of such client */ diagchar_ioctl(NULL, DIAG_IOCTL_DCI_DEINIT, 0); #ifdef CONFIG_DIAG_OVER_USB /* If the SD logging process exits, change logging to USB mode */ if (driver->logging_process_id == current->tgid) { driver->logging_mode = USB_MODE; diagfwd_connect(); #ifdef CONFIG_DIAG_HSIC_PIPE driver->num_hsic_buf_tbl_entries = 0; for (i = 0; i < driver->poolsize_hsic_write; i++) { if (driver->hsic_buf_tbl[i].buf) { /* Return the buffer to the pool */ diagmem_free(driver, (unsigned char *) (driver->hsic_buf_tbl[i].buf), POOL_TYPE_HSIC); driver->hsic_buf_tbl[i].buf = 0; driver->hsic_buf_tbl[i].length = 0; } } diagfwd_cancel_hsic(); diagfwd_connect_hsic(0); #endif } #endif /* DIAG over USB */ /* Delete the pkt response table entry for the exiting process */ for (i = 0; i < diag_max_reg; i++) if (driver->table[i].process_id == current->tgid) driver->table[i].process_id = 0; if (driver) { mutex_lock(&driver->diagchar_mutex); driver->ref_count--; /* On Client exit, try to destroy all 3 pools */ diagmem_exit(driver, POOL_TYPE_COPY); diagmem_exit(driver, POOL_TYPE_HDLC); diagmem_exit(driver, POOL_TYPE_WRITE_STRUCT); for (i = 0; i < driver->num_clients; i++) { if (NULL != diagpriv_data && diagpriv_data->pid == driver->client_map[i].pid) { driver->client_map[i].pid = 0; kfree(diagpriv_data); diagpriv_data = NULL; break; } } mutex_unlock(&driver->diagchar_mutex); return 0; } return -ENOMEM; }
static int diagchar_close(struct inode *inode, struct file *file) { int i = 0; struct diagchar_priv *diagpriv_data = file->private_data; pr_debug("diag: process exit %s\n", current->comm); if (!(file->private_data)) { pr_alert("diag: Invalid file pointer"); return -ENOMEM; } /* clean up any DCI registrations, if this is a DCI client * This will specially help in case of ungraceful exit of any DCI client * This call will remove any pending registrations of such client */ for (i = 0; i < MAX_DCI_CLIENTS; i++) { if (driver->dci_client_tbl[i].client && driver->dci_client_tbl[i].client->tgid == current->tgid) { diagchar_ioctl(NULL, DIAG_IOCTL_DCI_DEINIT, 0); break; } } /* If the exiting process is the socket process */ if (driver->socket_process && (driver->socket_process->tgid == current->tgid)) { driver->socket_process = NULL; } if (driver->callback_process && (driver->callback_process->tgid == current->tgid)) { driver->callback_process = NULL; } #ifdef CONFIG_DIAG_OVER_USB /* If the SD logging process exits, change logging to USB mode */ if (driver->logging_process_id == current->tgid) { driver->logging_mode = USB_MODE; diagfwd_connect(); #ifdef CONFIG_DIAG_BRIDGE_CODE diag_clear_hsic_tbl(); diagfwd_cancel_hsic(); diagfwd_connect_bridge(0); #endif } #endif /* DIAG over USB */ /* Delete the pkt response table entry for the exiting process */ for (i = 0; i < diag_max_reg; i++) if (driver->table[i].process_id == current->tgid) driver->table[i].process_id = 0; if (driver) { mutex_lock(&driver->diagchar_mutex); driver->ref_count--; /* On Client exit, try to destroy all 3 pools */ diagmem_exit(driver, POOL_TYPE_COPY); diagmem_exit(driver, POOL_TYPE_HDLC); diagmem_exit(driver, POOL_TYPE_WRITE_STRUCT); for (i = 0; i < driver->num_clients; i++) { if (NULL != diagpriv_data && diagpriv_data->pid == driver->client_map[i].pid) { driver->client_map[i].pid = 0; kfree(diagpriv_data); diagpriv_data = NULL; break; } } mutex_unlock(&driver->diagchar_mutex); return 0; } return -ENOMEM; }