static int mbox_debugfs_mbox_put(u32 index) { struct hisi_mbox *mbox = NULL; struct notifier_block *nb = NULL; int i; if (index > DEBUGFS_MBOXES_NUM || index < 1) return -EINVAL; mbox = debugfs_mboxes[index - 1].mbox; if (!mbox) return -EINVAL; else nb = debugfs_mboxes[index - 1].nb; hisi_mbox_put(&mbox); debugfs_mboxes[index - 1].mbox = NULL; kfree(debugfs_mboxes[index - 1].rp_name); debugfs_mboxes[index - 1].rp_name = NULL; kfree(nb); for (i = index; (i < DEBUGFS_MBOXES_NUM) && (debugfs_mboxes[i].mbox); i++) { debugfs_mboxes[i - 1].mbox = debugfs_mboxes[i].mbox; debugfs_mboxes[i - 1].nb = debugfs_mboxes[i].nb; debugfs_mboxes[i - 1].rp_name = debugfs_mboxes[i].rp_name; debugfs_mboxes[i].mbox = NULL; debugfs_mboxes[i].nb = NULL; debugfs_mboxes[i].rp_name = NULL; } return 0; }
static void __exit hisi_clkmbox_exit(void) { if (mbox_clk) { hisi_mbox_put(&mbox_clk->mbox); kfree(mbox_clk); mbox_clk = NULL; } unregister_pm_notifier(&mailbox_pm_notif_block); }
/* hisi adc exit function */ static void __exit hisi_adc_driver_exit(void) { if (hisi_adc_dev) { hisi_mbox_put(&hisi_adc_dev->mbox); kfree(hisi_adc_dev->nb); hisi_adc_dev->nb = NULL; kfree(hisi_adc_dev); hisi_adc_dev = NULL; } adc_remove_device_debugfs(); }
static int mbox_debugfs_mbox_get(char *name) { struct notifier_block *nb = NULL; struct hisi_mbox *mbox = NULL; char *rp_name = NULL; int i; if (!name) return -EINVAL; for (i = 0; (debugfs_mboxes[i].mbox) && (i < DEBUGFS_MBOXES_NUM); i++) ; if (i >= DEBUGFS_MBOXES_NUM) return -ENOMEM; nb = kmalloc(sizeof(*nb), GFP_KERNEL); if (!nb) return -ENOMEM; nb->next = NULL; nb->notifier_call = mbox_debugfs_notifier; mbox = hisi_mbox_get(name, nb); if (!mbox) { kfree(nb); return -ENODEV; } rp_name = kmalloc(sizeof(char) * (strlen(name) + 1), GFP_KERNEL); if (!rp_name) { hisi_mbox_put(&mbox); kfree(nb); return -ENOMEM; } strncpy(rp_name, name, strlen(name) + 1); *(rp_name + strlen(name)) = '\0'; MBOX_DEBUG_ON(mbox); debugfs_mboxes[i].mbox = mbox; debugfs_mboxes[i].nb = nb; debugfs_mboxes[i].rp_name = rp_name; debugfs_mboxes[i].initialized = 0; return 0; }
static void __exit inputhub_mcu_exit(void) { inputhub_route_exit(); if(lpm3_mbox) hisi_mbox_put(&lpm3_mbox); }
int inputhub_mcu_disconnect( void ) { hisi_mbox_put(&mbox); return 0; }