static int smc_remove(struct platform_device *pdev) { smc_dev_t *smc = (smc_dev_t*)dev_get_drvdata(&pdev->dev); mutex_lock(&smc_lock); smc_dev_deinit(smc); mutex_unlock(&smc_lock); return 0; }
static int smc_remove(struct platform_device *pdev) { smc_dev_t *smc = (smc_dev_t*)dev_get_drvdata(&pdev->dev); mutex_lock(&smc_lock); s_smc_task_state = 0; kthread_stop(s_smc_task); switch_dev_unregister(&sdev); smc_dev_deinit(smc); mutex_unlock(&smc_lock); return 0; }
static int smc_dev_init(smc_dev_t *smc, int id) { struct resource *res; char buf[32]; struct devio_aml_platform_data *pd_smc; smc->id = id; smc->reset_pin = smc0_reset; if(smc->reset_pin==-1) { snprintf(buf, sizeof(buf), "smc%d_reset", id); res = platform_get_resource_byname(smc->pdev, IORESOURCE_MEM, buf); if (!res) { pr_error("cannot get resource \"%s\"\n", buf); } else { smc->reset_pin = res->start; } } smc->irq_num = smc0_irq; if(smc->irq_num==-1) { snprintf(buf, sizeof(buf), "smc%d_irq", id); res = platform_get_resource_byname(smc->pdev, IORESOURCE_IRQ, buf); if (!res) { pr_error("cannot get resource \"%s\"\n", buf); return -1; } smc->irq_num = res->start; } init_waitqueue_head(&smc->rd_wq); init_waitqueue_head(&smc->wr_wq); spin_lock_init(&smc->slock); mutex_init(&smc->lock); pd_smc = (struct devio_aml_platform_data*)smc->pdev->dev.platform_data; if(pd_smc) { if(pd_smc->io_setup) pd_smc->io_setup(NULL); smc->reset = pd_smc->io_reset; } smc->irq_num=request_irq(smc->irq_num,(irq_handler_t)smc_irq_handler,IRQF_SHARED,"smc",smc); if(smc->irq_num<0) { pr_error("request irq error!\n"); smc_dev_deinit(smc); return -1; } snprintf(buf, sizeof(buf), "smc%d", smc->id); smc->dev=device_create(&smc_class, NULL, MKDEV(smc_major, smc->id), smc, buf); if(!smc->dev) { pr_error("create device error!\n"); smc_dev_deinit(smc); return -1; } smc->param.f = F_DEFAULT; smc->param.d = D_DEFAULT; smc->param.n = N_DEFAULT; smc->param.bwi = BWI_DEFAULT; smc->param.cwi = CWI_DEFAULT; smc->param.bgt = BGT_DEFAULT; smc->param.freq = FREQ_DEFAULT; smc->param.recv_invert = 0; smc->param.recv_lsb_msb = 0; smc->param.recv_no_parity = 1; smc->param.xmit_invert = 0; smc->param.xmit_lsb_msb = 0; smc->param.xmit_retries = 1; smc->param.xmit_repeat_dis = 1; smc->init = 1; smc_hw_setup(smc); return 0; }