示例#1
0
static int tdm_fsl_remove(struct platform_device *ofdev)
{
	struct tdm_priv *priv;
	int buf_size;
	struct tdm_adapter *adap;

	if (!ofdev) {
		pr_err("%s: Invalid handle\n", __func__);
		return -EINVAL;
	}

	priv = dev_get_drvdata(&ofdev->dev);
	adap = priv->adap;

	tdm_fsl_disable(priv->adap);

	tdm_fsl_stop(priv);

	tdm_del_adapter(priv->adap);
	dev_set_drvdata(&ofdev->dev, NULL);

	/* free the irqs and dispose their mapping */
	free_irq(priv->tdm_err_intr, priv);
	free_irq(priv->dmac_done_intr, priv);
	irq_dispose_mapping(priv->tdm_err_intr);
	irq_dispose_mapping(priv->dmac_done_intr);
	iounmap(priv->tdm_regs);
	iounmap(priv->dmac_regs);

	/* free the buffers */
	buf_size =
	    TDM_BUF_SIZE(adap->adapt_cfg.num_ch, adap->adapt_cfg.slot_width,
			 adap->adapt_cfg.num_frames);
	dma_free_coherent(priv->device, buf_size, priv->dma_input_vaddr,
			  priv->dma_input_paddr);
	dma_free_coherent(priv->device, buf_size, priv->dma_output_vaddr,
			  priv->dma_output_paddr);

	/* free the TCDs */
	dma_free_coherent(priv->device, NUM_OF_TDM_BUF * TCD_BUFFER_SIZE,
		priv->dma_rx_tcd_vaddr,  priv->dma_rx_tcd_paddr);
	dma_free_coherent(priv->device, NUM_OF_TDM_BUF * TCD_BUFFER_SIZE,
		priv->dma_tx_tcd_vaddr,  priv->dma_tx_tcd_paddr);
	dev_set_drvdata(&ofdev->dev, NULL);
	kfree(priv);
	return 0;
}
static int __devexit tdm_fsl_starlite_remove(struct of_device *ofdev)
{
	struct tdm_priv *priv = dev_get_drvdata(&ofdev->dev);
	int buf_size;

	tdm_fsl_starlite_disable(priv->adap);

	tdm_fsl_starlite_stop(priv);

	tdm_del_adapter(priv->adap);
	dev_set_drvdata(&ofdev->dev, NULL);

	/* free the irqs and dispose their mapping */
	free_irq(priv->tdm_err_intr, priv);
	free_irq(priv->dmac_done_intr, priv);
	irq_dispose_mapping(priv->tdm_err_intr);
	irq_dispose_mapping(priv->dmac_done_intr);
	iounmap(priv->tdm_regs);
	iounmap(priv->dmac_regs);

	/* free the buffers */
	buf_size =
	    TDM_BUF_SIZE(priv->cfg.num_ch, priv->cfg.ch_width,
			 priv->cfg.num_frames);
	dma_free_coherent(priv->device, buf_size, priv->dma_input_vaddr,
			  priv->dma_input_paddr);
	dma_free_coherent(priv->device, buf_size, priv->dma_output_vaddr,
			  priv->dma_output_paddr);

	/* free the TCDs */
	dma_free_coherent(priv->device, NUM_OF_TDM_BUF * TCD_BUFFER_SIZE,
		priv->dma_rx_tcd_vaddr,  priv->dma_rx_tcd_paddr);
	dma_free_coherent(priv->device, NUM_OF_TDM_BUF * TCD_BUFFER_SIZE,
		priv->dma_tx_tcd_vaddr,  priv->dma_tx_tcd_paddr);
	dev_set_drvdata(&ofdev->dev, NULL);
	kfree(priv);
	return 0;
}