static int __devexit pil_dsps_driver_exit(struct platform_device *pdev) { struct dsps_data *drv = platform_get_drvdata(pdev); smsm_state_cb_deregister(SMSM_DSPS_STATE, SMSM_RESET, dsps_smsm_state_cb, drv); subsys_unregister(drv->subsys); destroy_ramdump_device(drv->smem_ramdump_dev); destroy_ramdump_device(drv->ramdump_dev); pil_desc_release(&drv->desc); return 0; }
static int __devexit pil_riva_remove(struct platform_device *pdev) { struct riva_data *drv = platform_get_drvdata(pdev); subsys_unregister(drv->subsys); destroy_ramdump_device(drv->ramdump_dev); smsm_state_cb_deregister(SMSM_WCNSS_STATE, SMSM_RESET, smsm_state_cb_hdlr, drv); pil_desc_release(&drv->pil_desc); return 0; }
static int modem_shutdown(const struct subsys_data *subsys) { void __iomem *q6_fw_wdog_addr; void __iomem *q6_sw_wdog_addr; int smsm_notif_unregistered = 0; if (!(smsm_get_state(SMSM_MODEM_STATE) & SMSM_RESET)) { smsm_state_cb_deregister(SMSM_MODEM_STATE, SMSM_RESET, smsm_state_cb, 0); smsm_notif_unregistered = 1; smsm_reset_modem(SMSM_RESET); } /* * Cancel any pending wdog_check work items, since we're shutting * down anyway. */ cancel_delayed_work(&modem_wdog_check_work); /* * Disable the modem watchdog since it keeps running even after the * modem is shutdown. */ q6_fw_wdog_addr = ioremap_nocache(Q6_FW_WDOG_ENABLE, 4); if (!q6_fw_wdog_addr) return -ENOMEM; q6_sw_wdog_addr = ioremap_nocache(Q6_SW_WDOG_ENABLE, 4); if (!q6_sw_wdog_addr) { iounmap(q6_fw_wdog_addr); return -ENOMEM; } writel_relaxed(0x0, q6_fw_wdog_addr); writel_relaxed(0x0, q6_sw_wdog_addr); mb(); iounmap(q6_sw_wdog_addr); iounmap(q6_fw_wdog_addr); pil_force_shutdown("modem"); pil_force_shutdown("modem_fw"); disable_irq_nosync(Q6FW_WDOG_EXPIRED_IRQ); disable_irq_nosync(Q6SW_WDOG_EXPIRED_IRQ); if (smsm_notif_unregistered) smsm_state_cb_register(SMSM_MODEM_STATE, SMSM_RESET, smsm_state_cb, 0); return 0; }
static int pil_q6v4_modem_driver_exit(struct platform_device *pdev) { struct q6v4_modem *drv = platform_get_drvdata(pdev); smsm_state_cb_deregister(SMSM_MODEM_STATE, SMSM_RESET, smsm_state_cb, drv); subsys_unregister(drv->subsys); destroy_ramdump_device(drv->smem_ramdump_dev); destroy_ramdump_device(drv->sw_ramdump_dev); destroy_ramdump_device(drv->fw_ramdump_dev); if (drv->loadable) { msm_pil_unregister(drv->q6_sw.pil); msm_pil_unregister(drv->q6_fw.pil); } return 0; }
static int __init riva_ssr_module_init(void) { int ret; ret = smsm_state_cb_register(SMSM_WCNSS_STATE, SMSM_RESET, smsm_state_cb_hdlr, 0); if (ret < 0) { pr_err("%s: Unable to register smsm callback for Riva Reset!" " (%d)\n", MODULE_NAME, ret); goto out; } ret = request_irq(RIVA_APSS_WDOG_BITE_RESET_RDY_IRQ, riva_wdog_bite_irq_hdlr, IRQF_TRIGGER_HIGH, "riva_wdog", NULL); if (ret < 0) { pr_err("%s: Unable to register for Riva bite interrupt" " (%d)\n", MODULE_NAME, ret); goto out1; } ret = riva_restart_init(); if (ret < 0) { pr_err("%s: Unable to register with ssr. (%d)\n", MODULE_NAME, ret); goto out2; } riva_ramdump_dev = create_ramdump_device("riva"); if (!riva_ramdump_dev) { pr_err("%s: Unable to create ramdump device.\n", MODULE_NAME); ret = -ENOMEM; goto out2; } INIT_DELAYED_WORK(&cancel_vote_work, riva_post_bootup); pr_info("%s: module initialized\n", MODULE_NAME); return ret; out2: free_irq(RIVA_APSS_WDOG_BITE_RESET_RDY_IRQ, NULL); out1: smsm_state_cb_deregister(SMSM_WCNSS_STATE, SMSM_RESET, smsm_state_cb_hdlr, 0); out: return ret; }
static int __devinit pil_riva_probe(struct platform_device *pdev) { struct riva_data *drv; struct resource *res; struct pil_desc *desc; int ret; drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); if (!drv) return -ENOMEM; platform_set_drvdata(pdev, drv); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); drv->base = devm_request_and_ioremap(&pdev->dev, res); if (!drv->base) return -ENOMEM; res = platform_get_resource(pdev, IORESOURCE_MEM, 1); drv->cbase = devm_request_and_ioremap(&pdev->dev, res); if (!drv->cbase) return -ENOMEM; drv->pll_supply = devm_regulator_get(&pdev->dev, "pll_vdd"); if (IS_ERR(drv->pll_supply)) { dev_err(&pdev->dev, "failed to get pll supply\n"); return PTR_ERR(drv->pll_supply); } if (regulator_count_voltages(drv->pll_supply) > 0) { ret = regulator_set_voltage(drv->pll_supply, 1800000, 1800000); if (ret) { dev_err(&pdev->dev, "failed to set pll supply voltage\n"); return ret; } ret = regulator_set_optimum_mode(drv->pll_supply, 100000); if (ret < 0) { dev_err(&pdev->dev, "failed to set pll supply optimum mode\n"); return ret; } } drv->irq = platform_get_irq(pdev, 0); if (drv->irq < 0) return drv->irq; drv->xo = devm_clk_get(&pdev->dev, "cxo"); if (IS_ERR(drv->xo)) return PTR_ERR(drv->xo); desc = &drv->pil_desc; desc->name = "wcnss"; desc->dev = &pdev->dev; desc->owner = THIS_MODULE; desc->proxy_timeout = 10000; if (pas_supported(PAS_WCNSS) > 0) { desc->ops = &pil_riva_ops_trusted; dev_info(&pdev->dev, "using secure boot\n"); } else { desc->ops = &pil_riva_ops; dev_info(&pdev->dev, "using non-secure boot\n"); } ret = pil_desc_init(desc); ret = smsm_state_cb_register(SMSM_WCNSS_STATE, SMSM_RESET, smsm_state_cb_hdlr, drv); if (ret < 0) goto err_smsm; drv->subsys_desc.name = "wcnss"; drv->subsys_desc.dev = &pdev->dev; drv->subsys_desc.owner = THIS_MODULE; drv->subsys_desc.start = riva_start; drv->subsys_desc.stop = riva_stop; drv->subsys_desc.shutdown = riva_shutdown; drv->subsys_desc.powerup = riva_powerup; drv->subsys_desc.ramdump = riva_ramdump; drv->subsys_desc.crash_shutdown = riva_crash_shutdown; INIT_DELAYED_WORK(&drv->cancel_work, riva_post_bootup); drv->ramdump_dev = create_ramdump_device("riva", &pdev->dev); if (!drv->ramdump_dev) { ret = -ENOMEM; goto err_ramdump; } drv->subsys = subsys_register(&drv->subsys_desc); if (IS_ERR(drv->subsys)) { ret = PTR_ERR(drv->subsys); goto err_subsys; } scm_pas_init(MSM_BUS_MASTER_SPS); ret = devm_request_irq(&pdev->dev, drv->irq, riva_wdog_bite_irq_hdlr, IRQF_TRIGGER_RISING, "riva_wdog", drv); if (ret < 0) goto err; return 0; err: subsys_unregister(drv->subsys); err_subsys: destroy_ramdump_device(drv->ramdump_dev); err_ramdump: smsm_state_cb_deregister(SMSM_WCNSS_STATE, SMSM_RESET, smsm_state_cb_hdlr, drv); err_smsm: pil_desc_release(desc); return ret; }
/** * platform driver * */ static int __devinit dsps_probe(struct platform_device *pdev) { int ret; pr_debug("%s.\n", __func__); if (pdev->dev.platform_data == NULL) { pr_err("%s: platform data is NULL.\n", __func__); return -ENODEV; } drv = kzalloc(sizeof(*drv), GFP_KERNEL); if (drv == NULL) { pr_err("%s: kzalloc fail.\n", __func__); goto alloc_err; } drv->pdata = pdev->dev.platform_data; drv->dev_class = class_create(THIS_MODULE, DRV_NAME); if (drv->dev_class == NULL) { pr_err("%s: class_create fail.\n", __func__); goto res_err; } ret = alloc_chrdev_region(&drv->dev_num, 0, 1, DRV_NAME); if (ret) { pr_err("%s: alloc_chrdev_region fail.\n", __func__); goto alloc_chrdev_region_err; } drv->dev = device_create(drv->dev_class, NULL, drv->dev_num, drv, DRV_NAME); if (IS_ERR(drv->dev)) { pr_err("%s: device_create fail.\n", __func__); goto device_create_err; } drv->cdev = cdev_alloc(); if (drv->cdev == NULL) { pr_err("%s: cdev_alloc fail.\n", __func__); goto cdev_alloc_err; } cdev_init(drv->cdev, &dsps_fops); drv->cdev->owner = THIS_MODULE; ret = cdev_add(drv->cdev, drv->dev_num, 1); if (ret) { pr_err("%s: cdev_add fail.\n", __func__); goto cdev_add_err; } ret = dsps_alloc_resources(pdev); if (ret) { pr_err("%s: failed to allocate dsps resources.\n", __func__); goto cdev_add_err; } ret = smsm_state_cb_register(SMSM_DSPS_STATE, SMSM_RESET, dsps_smsm_state_cb, 0); if (ret) { pr_err("%s: smsm_state_cb_register fail %d\n", __func__, ret); goto smsm_register_err; } ret = ssr_register_subsystem(&dsps_ssrops); if (ret) { pr_err("%s: ssr_register_subsystem fail %d\n", __func__, ret); goto ssr_register_err; } return 0; ssr_register_err: smsm_state_cb_deregister(SMSM_DSPS_STATE, SMSM_RESET, dsps_smsm_state_cb, 0); smsm_register_err: cdev_del(drv->cdev); cdev_add_err: kfree(drv->cdev); cdev_alloc_err: device_destroy(drv->dev_class, drv->dev_num); device_create_err: unregister_chrdev_region(drv->dev_num, 1); alloc_chrdev_region_err: class_destroy(drv->dev_class); res_err: kfree(drv); drv = NULL; alloc_err: return -ENODEV; }
static int debug_test_smsm(char *buf, int max) { int i = 0; int test_num = 0; int ret; /* Test case 1 - Register new callback for notification */ do { test_num++; SMSM_CB_TEST_INIT(); ret = smsm_state_cb_register(SMSM_APPS_STATE, SMSM_SMDINIT, smsm_state_cb, (void *)0x1234); UT_EQ_INT(ret, 0); /* de-assert SMSM_SMD_INIT to trigger state update */ UT_EQ_INT(smsm_cb_data.cb_count, 0); INIT_COMPLETION(smsm_cb_completion); smsm_change_state(SMSM_APPS_STATE, SMSM_SMDINIT, 0x0); UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion, msecs_to_jiffies(20)), 0); UT_EQ_INT(smsm_cb_data.cb_count, 1); UT_EQ_INT(smsm_cb_data.old_state & SMSM_SMDINIT, SMSM_SMDINIT); UT_EQ_INT(smsm_cb_data.new_state & SMSM_SMDINIT, 0x0); UT_EQ_INT((int)smsm_cb_data.data, 0x1234); /* re-assert SMSM_SMD_INIT to trigger state update */ INIT_COMPLETION(smsm_cb_completion); smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_SMDINIT); UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion, msecs_to_jiffies(20)), 0); UT_EQ_INT(smsm_cb_data.cb_count, 2); UT_EQ_INT(smsm_cb_data.old_state & SMSM_SMDINIT, 0x0); UT_EQ_INT(smsm_cb_data.new_state & SMSM_SMDINIT, SMSM_SMDINIT); /* deregister callback */ ret = smsm_state_cb_deregister(SMSM_APPS_STATE, SMSM_SMDINIT, smsm_state_cb, (void *)0x1234); UT_EQ_INT(ret, 2); /* make sure state change doesn't cause any more callbacks */ INIT_COMPLETION(smsm_cb_completion); smsm_change_state(SMSM_APPS_STATE, SMSM_SMDINIT, 0x0); smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_SMDINIT); UT_EQ_INT((int)wait_for_completion_timeout(&smsm_cb_completion, msecs_to_jiffies(20)), 0); UT_EQ_INT(smsm_cb_data.cb_count, 2); i += scnprintf(buf + i, max - i, "Test %d - PASS\n", test_num); } while (0); /* Test case 2 - Update already registered callback */ do { test_num++; SMSM_CB_TEST_INIT(); ret = smsm_state_cb_register(SMSM_APPS_STATE, SMSM_SMDINIT, smsm_state_cb, (void *)0x1234); UT_EQ_INT(ret, 0); ret = smsm_state_cb_register(SMSM_APPS_STATE, SMSM_INIT, smsm_state_cb, (void *)0x1234); UT_EQ_INT(ret, 1); /* verify both callback bits work */ INIT_COMPLETION(smsm_cb_completion); UT_EQ_INT(smsm_cb_data.cb_count, 0); smsm_change_state(SMSM_APPS_STATE, SMSM_SMDINIT, 0x0); UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion, msecs_to_jiffies(20)), 0); UT_EQ_INT(smsm_cb_data.cb_count, 1); INIT_COMPLETION(smsm_cb_completion); smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_SMDINIT); UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion, msecs_to_jiffies(20)), 0); UT_EQ_INT(smsm_cb_data.cb_count, 2); INIT_COMPLETION(smsm_cb_completion); smsm_change_state(SMSM_APPS_STATE, SMSM_INIT, 0x0); UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion, msecs_to_jiffies(20)), 0); UT_EQ_INT(smsm_cb_data.cb_count, 3); INIT_COMPLETION(smsm_cb_completion); smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_INIT); UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion, msecs_to_jiffies(20)), 0); UT_EQ_INT(smsm_cb_data.cb_count, 4); /* deregister 1st callback */ ret = smsm_state_cb_deregister(SMSM_APPS_STATE, SMSM_SMDINIT, smsm_state_cb, (void *)0x1234); UT_EQ_INT(ret, 1); INIT_COMPLETION(smsm_cb_completion); smsm_change_state(SMSM_APPS_STATE, SMSM_SMDINIT, 0x0); smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_SMDINIT); UT_EQ_INT((int)wait_for_completion_timeout(&smsm_cb_completion, msecs_to_jiffies(20)), 0); UT_EQ_INT(smsm_cb_data.cb_count, 4); INIT_COMPLETION(smsm_cb_completion); smsm_change_state(SMSM_APPS_STATE, SMSM_INIT, 0x0); UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion, msecs_to_jiffies(20)), 0); UT_EQ_INT(smsm_cb_data.cb_count, 5); INIT_COMPLETION(smsm_cb_completion); smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_INIT); UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion, msecs_to_jiffies(20)), 0); UT_EQ_INT(smsm_cb_data.cb_count, 6); /* deregister 2nd callback */ ret = smsm_state_cb_deregister(SMSM_APPS_STATE, SMSM_INIT, smsm_state_cb, (void *)0x1234); UT_EQ_INT(ret, 2); /* make sure state change doesn't cause any more callbacks */ INIT_COMPLETION(smsm_cb_completion); smsm_change_state(SMSM_APPS_STATE, SMSM_INIT, 0x0); smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_INIT); UT_EQ_INT((int)wait_for_completion_timeout(&smsm_cb_completion, msecs_to_jiffies(20)), 0); UT_EQ_INT(smsm_cb_data.cb_count, 6); i += scnprintf(buf + i, max - i, "Test %d - PASS\n", test_num); } while (0); /* Test case 3 - Two callback registrations with different data */ do { test_num++; SMSM_CB_TEST_INIT(); ret = smsm_state_cb_register(SMSM_APPS_STATE, SMSM_SMDINIT, smsm_state_cb, (void *)0x1234); UT_EQ_INT(ret, 0); ret = smsm_state_cb_register(SMSM_APPS_STATE, SMSM_INIT, smsm_state_cb, (void *)0x3456); UT_EQ_INT(ret, 0); /* verify both callbacks work */ INIT_COMPLETION(smsm_cb_completion); UT_EQ_INT(smsm_cb_data.cb_count, 0); smsm_change_state(SMSM_APPS_STATE, SMSM_SMDINIT, 0x0); UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion, msecs_to_jiffies(20)), 0); UT_EQ_INT(smsm_cb_data.cb_count, 1); UT_EQ_INT((int)smsm_cb_data.data, 0x1234); INIT_COMPLETION(smsm_cb_completion); smsm_change_state(SMSM_APPS_STATE, SMSM_INIT, 0x0); UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion, msecs_to_jiffies(20)), 0); UT_EQ_INT(smsm_cb_data.cb_count, 2); UT_EQ_INT((int)smsm_cb_data.data, 0x3456); /* cleanup and unregister * degregister in reverse to verify data field is * being used */ smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_SMDINIT); smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_INIT); ret = smsm_state_cb_deregister(SMSM_APPS_STATE, SMSM_INIT, smsm_state_cb, (void *)0x3456); UT_EQ_INT(ret, 2); ret = smsm_state_cb_deregister(SMSM_APPS_STATE, SMSM_SMDINIT, smsm_state_cb, (void *)0x1234); UT_EQ_INT(ret, 2); i += scnprintf(buf + i, max - i, "Test %d - PASS\n", test_num); } while (0); return i; }
static int debug_test_smsm(char *buf, int max) { int i = 0; int test_num = 0; int ret; do { test_num++; SMSM_CB_TEST_INIT(); ret = smsm_state_cb_register(SMSM_APPS_STATE, SMSM_SMDINIT, smsm_state_cb, (void *)0x1234); UT_EQ_INT(ret, 0); UT_EQ_INT(smsm_cb_data.cb_count, 0); INIT_COMPLETION(smsm_cb_completion); smsm_change_state(SMSM_APPS_STATE, SMSM_SMDINIT, 0x0); UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion, msecs_to_jiffies(20)), 0); UT_EQ_INT(smsm_cb_data.cb_count, 1); UT_EQ_INT(smsm_cb_data.old_state & SMSM_SMDINIT, SMSM_SMDINIT); UT_EQ_INT(smsm_cb_data.new_state & SMSM_SMDINIT, 0x0); UT_EQ_INT((int)smsm_cb_data.data, 0x1234); INIT_COMPLETION(smsm_cb_completion); smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_SMDINIT); UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion, msecs_to_jiffies(20)), 0); UT_EQ_INT(smsm_cb_data.cb_count, 2); UT_EQ_INT(smsm_cb_data.old_state & SMSM_SMDINIT, 0x0); UT_EQ_INT(smsm_cb_data.new_state & SMSM_SMDINIT, SMSM_SMDINIT); ret = smsm_state_cb_deregister(SMSM_APPS_STATE, SMSM_SMDINIT, smsm_state_cb, (void *)0x1234); UT_EQ_INT(ret, 2); INIT_COMPLETION(smsm_cb_completion); smsm_change_state(SMSM_APPS_STATE, SMSM_SMDINIT, 0x0); smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_SMDINIT); UT_EQ_INT((int)wait_for_completion_timeout(&smsm_cb_completion, msecs_to_jiffies(20)), 0); UT_EQ_INT(smsm_cb_data.cb_count, 2); i += scnprintf(buf + i, max - i, "Test %d - PASS\n", test_num); } while (0); do { test_num++; SMSM_CB_TEST_INIT(); ret = smsm_state_cb_register(SMSM_APPS_STATE, SMSM_SMDINIT, smsm_state_cb, (void *)0x1234); UT_EQ_INT(ret, 0); ret = smsm_state_cb_register(SMSM_APPS_STATE, SMSM_INIT, smsm_state_cb, (void *)0x1234); UT_EQ_INT(ret, 1); INIT_COMPLETION(smsm_cb_completion); UT_EQ_INT(smsm_cb_data.cb_count, 0); smsm_change_state(SMSM_APPS_STATE, SMSM_SMDINIT, 0x0); UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion, msecs_to_jiffies(20)), 0); UT_EQ_INT(smsm_cb_data.cb_count, 1); INIT_COMPLETION(smsm_cb_completion); smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_SMDINIT); UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion, msecs_to_jiffies(20)), 0); UT_EQ_INT(smsm_cb_data.cb_count, 2); INIT_COMPLETION(smsm_cb_completion); smsm_change_state(SMSM_APPS_STATE, SMSM_INIT, 0x0); UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion, msecs_to_jiffies(20)), 0); UT_EQ_INT(smsm_cb_data.cb_count, 3); INIT_COMPLETION(smsm_cb_completion); smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_INIT); UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion, msecs_to_jiffies(20)), 0); UT_EQ_INT(smsm_cb_data.cb_count, 4); ret = smsm_state_cb_deregister(SMSM_APPS_STATE, SMSM_SMDINIT, smsm_state_cb, (void *)0x1234); UT_EQ_INT(ret, 1); INIT_COMPLETION(smsm_cb_completion); smsm_change_state(SMSM_APPS_STATE, SMSM_SMDINIT, 0x0); smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_SMDINIT); UT_EQ_INT((int)wait_for_completion_timeout(&smsm_cb_completion, msecs_to_jiffies(20)), 0); UT_EQ_INT(smsm_cb_data.cb_count, 4); INIT_COMPLETION(smsm_cb_completion); smsm_change_state(SMSM_APPS_STATE, SMSM_INIT, 0x0); UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion, msecs_to_jiffies(20)), 0); UT_EQ_INT(smsm_cb_data.cb_count, 5); INIT_COMPLETION(smsm_cb_completion); smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_INIT); UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion, msecs_to_jiffies(20)), 0); UT_EQ_INT(smsm_cb_data.cb_count, 6); ret = smsm_state_cb_deregister(SMSM_APPS_STATE, SMSM_INIT, smsm_state_cb, (void *)0x1234); UT_EQ_INT(ret, 2); INIT_COMPLETION(smsm_cb_completion); smsm_change_state(SMSM_APPS_STATE, SMSM_INIT, 0x0); smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_INIT); UT_EQ_INT((int)wait_for_completion_timeout(&smsm_cb_completion, msecs_to_jiffies(20)), 0); UT_EQ_INT(smsm_cb_data.cb_count, 6); i += scnprintf(buf + i, max - i, "Test %d - PASS\n", test_num); } while (0); do { test_num++; SMSM_CB_TEST_INIT(); ret = smsm_state_cb_register(SMSM_APPS_STATE, SMSM_SMDINIT, smsm_state_cb, (void *)0x1234); UT_EQ_INT(ret, 0); ret = smsm_state_cb_register(SMSM_APPS_STATE, SMSM_INIT, smsm_state_cb, (void *)0x3456); UT_EQ_INT(ret, 0); INIT_COMPLETION(smsm_cb_completion); UT_EQ_INT(smsm_cb_data.cb_count, 0); smsm_change_state(SMSM_APPS_STATE, SMSM_SMDINIT, 0x0); UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion, msecs_to_jiffies(20)), 0); UT_EQ_INT(smsm_cb_data.cb_count, 1); UT_EQ_INT((int)smsm_cb_data.data, 0x1234); INIT_COMPLETION(smsm_cb_completion); smsm_change_state(SMSM_APPS_STATE, SMSM_INIT, 0x0); UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion, msecs_to_jiffies(20)), 0); UT_EQ_INT(smsm_cb_data.cb_count, 2); UT_EQ_INT((int)smsm_cb_data.data, 0x3456); smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_SMDINIT); smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_INIT); ret = smsm_state_cb_deregister(SMSM_APPS_STATE, SMSM_INIT, smsm_state_cb, (void *)0x3456); UT_EQ_INT(ret, 2); ret = smsm_state_cb_deregister(SMSM_APPS_STATE, SMSM_SMDINIT, smsm_state_cb, (void *)0x1234); UT_EQ_INT(ret, 2); i += scnprintf(buf + i, max - i, "Test %d - PASS\n", test_num); } while (0); return i; }