Commit e327e21f authored by Daniel Mack's avatar Daniel Mack Committed by Vinod Koul

dma: cppi41: pass around device instead of platform_device

Instead of passing around struct plafform_device, use struct device and
save one level of dereferencing. This affects the following functions:

 * cppi41_add_chans
 * purge_descs
 * deinit_cpii41
 * init_descs
 * init_cppi41
 * cppi_glue_infos

It's just a cosmetic cleanup that makes the code more readable.
Signed-off-by: default avatarDaniel Mack <zonque@gmail.com>
Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
parent 404ff669
...@@ -674,14 +674,14 @@ static void cleanup_chans(struct cppi41_dd *cdd) ...@@ -674,14 +674,14 @@ static void cleanup_chans(struct cppi41_dd *cdd)
} }
} }
static int cppi41_add_chans(struct platform_device *pdev, struct cppi41_dd *cdd) static int cppi41_add_chans(struct device *dev, struct cppi41_dd *cdd)
{ {
struct cppi41_channel *cchan; struct cppi41_channel *cchan;
int i; int i;
int ret; int ret;
u32 n_chans; u32 n_chans;
ret = of_property_read_u32(pdev->dev.of_node, "#dma-channels", ret = of_property_read_u32(dev->of_node, "#dma-channels",
&n_chans); &n_chans);
if (ret) if (ret)
return ret; return ret;
...@@ -719,7 +719,7 @@ static int cppi41_add_chans(struct platform_device *pdev, struct cppi41_dd *cdd) ...@@ -719,7 +719,7 @@ static int cppi41_add_chans(struct platform_device *pdev, struct cppi41_dd *cdd)
return -ENOMEM; return -ENOMEM;
} }
static void purge_descs(struct platform_device *pdev, struct cppi41_dd *cdd) static void purge_descs(struct device *dev, struct cppi41_dd *cdd)
{ {
unsigned int mem_decs; unsigned int mem_decs;
int i; int i;
...@@ -731,7 +731,7 @@ static void purge_descs(struct platform_device *pdev, struct cppi41_dd *cdd) ...@@ -731,7 +731,7 @@ static void purge_descs(struct platform_device *pdev, struct cppi41_dd *cdd)
cppi_writel(0, cdd->qmgr_mem + QMGR_MEMBASE(i)); cppi_writel(0, cdd->qmgr_mem + QMGR_MEMBASE(i));
cppi_writel(0, cdd->qmgr_mem + QMGR_MEMCTRL(i)); cppi_writel(0, cdd->qmgr_mem + QMGR_MEMCTRL(i));
dma_free_coherent(&pdev->dev, mem_decs, cdd->cd, dma_free_coherent(dev, mem_decs, cdd->cd,
cdd->descs_phys); cdd->descs_phys);
} }
} }
...@@ -741,19 +741,19 @@ static void disable_sched(struct cppi41_dd *cdd) ...@@ -741,19 +741,19 @@ static void disable_sched(struct cppi41_dd *cdd)
cppi_writel(0, cdd->sched_mem + DMA_SCHED_CTRL); cppi_writel(0, cdd->sched_mem + DMA_SCHED_CTRL);
} }
static void deinit_cpii41(struct platform_device *pdev, struct cppi41_dd *cdd) static void deinit_cpii41(struct device *dev, struct cppi41_dd *cdd)
{ {
disable_sched(cdd); disable_sched(cdd);
purge_descs(pdev, cdd); purge_descs(dev, cdd);
cppi_writel(0, cdd->qmgr_mem + QMGR_LRAM0_BASE); cppi_writel(0, cdd->qmgr_mem + QMGR_LRAM0_BASE);
cppi_writel(0, cdd->qmgr_mem + QMGR_LRAM0_BASE); cppi_writel(0, cdd->qmgr_mem + QMGR_LRAM0_BASE);
dma_free_coherent(&pdev->dev, QMGR_SCRATCH_SIZE, cdd->qmgr_scratch, dma_free_coherent(dev, QMGR_SCRATCH_SIZE, cdd->qmgr_scratch,
cdd->scratch_phys); cdd->scratch_phys);
} }
static int init_descs(struct platform_device *pdev, struct cppi41_dd *cdd) static int init_descs(struct device *dev, struct cppi41_dd *cdd)
{ {
unsigned int desc_size; unsigned int desc_size;
unsigned int mem_decs; unsigned int mem_decs;
...@@ -777,7 +777,7 @@ static int init_descs(struct platform_device *pdev, struct cppi41_dd *cdd) ...@@ -777,7 +777,7 @@ static int init_descs(struct platform_device *pdev, struct cppi41_dd *cdd)
reg |= ilog2(ALLOC_DECS_NUM) - 5; reg |= ilog2(ALLOC_DECS_NUM) - 5;
BUILD_BUG_ON(DESCS_AREAS != 1); BUILD_BUG_ON(DESCS_AREAS != 1);
cdd->cd = dma_alloc_coherent(&pdev->dev, mem_decs, cdd->cd = dma_alloc_coherent(dev, mem_decs,
&cdd->descs_phys, GFP_KERNEL); &cdd->descs_phys, GFP_KERNEL);
if (!cdd->cd) if (!cdd->cd)
return -ENOMEM; return -ENOMEM;
...@@ -813,12 +813,12 @@ static void init_sched(struct cppi41_dd *cdd) ...@@ -813,12 +813,12 @@ static void init_sched(struct cppi41_dd *cdd)
cppi_writel(reg, cdd->sched_mem + DMA_SCHED_CTRL); cppi_writel(reg, cdd->sched_mem + DMA_SCHED_CTRL);
} }
static int init_cppi41(struct platform_device *pdev, struct cppi41_dd *cdd) static int init_cppi41(struct device *dev, struct cppi41_dd *cdd)
{ {
int ret; int ret;
BUILD_BUG_ON(QMGR_SCRATCH_SIZE > ((1 << 14) - 1)); BUILD_BUG_ON(QMGR_SCRATCH_SIZE > ((1 << 14) - 1));
cdd->qmgr_scratch = dma_alloc_coherent(&pdev->dev, QMGR_SCRATCH_SIZE, cdd->qmgr_scratch = dma_alloc_coherent(dev, QMGR_SCRATCH_SIZE,
&cdd->scratch_phys, GFP_KERNEL); &cdd->scratch_phys, GFP_KERNEL);
if (!cdd->qmgr_scratch) if (!cdd->qmgr_scratch)
return -ENOMEM; return -ENOMEM;
...@@ -827,7 +827,7 @@ static int init_cppi41(struct platform_device *pdev, struct cppi41_dd *cdd) ...@@ -827,7 +827,7 @@ static int init_cppi41(struct platform_device *pdev, struct cppi41_dd *cdd)
cppi_writel(QMGR_SCRATCH_SIZE, cdd->qmgr_mem + QMGR_LRAM_SIZE); cppi_writel(QMGR_SCRATCH_SIZE, cdd->qmgr_mem + QMGR_LRAM_SIZE);
cppi_writel(0, cdd->qmgr_mem + QMGR_LRAM1_BASE); cppi_writel(0, cdd->qmgr_mem + QMGR_LRAM1_BASE);
ret = init_descs(pdev, cdd); ret = init_descs(dev, cdd);
if (ret) if (ret)
goto err_td; goto err_td;
...@@ -835,7 +835,7 @@ static int init_cppi41(struct platform_device *pdev, struct cppi41_dd *cdd) ...@@ -835,7 +835,7 @@ static int init_cppi41(struct platform_device *pdev, struct cppi41_dd *cdd)
init_sched(cdd); init_sched(cdd);
return 0; return 0;
err_td: err_td:
deinit_cpii41(pdev, cdd); deinit_cpii41(dev, cdd);
return ret; return ret;
} }
...@@ -914,11 +914,11 @@ static const struct of_device_id cppi41_dma_ids[] = { ...@@ -914,11 +914,11 @@ static const struct of_device_id cppi41_dma_ids[] = {
}; };
MODULE_DEVICE_TABLE(of, cppi41_dma_ids); MODULE_DEVICE_TABLE(of, cppi41_dma_ids);
static const struct cppi_glue_infos *get_glue_info(struct platform_device *pdev) static const struct cppi_glue_infos *get_glue_info(struct device *dev)
{ {
const struct of_device_id *of_id; const struct of_device_id *of_id;
of_id = of_match_node(cppi41_dma_ids, pdev->dev.of_node); of_id = of_match_node(cppi41_dma_ids, dev->of_node);
if (!of_id) if (!of_id)
return NULL; return NULL;
return of_id->data; return of_id->data;
...@@ -931,7 +931,7 @@ static int cppi41_dma_probe(struct platform_device *pdev) ...@@ -931,7 +931,7 @@ static int cppi41_dma_probe(struct platform_device *pdev)
int irq; int irq;
int ret; int ret;
glue_info = get_glue_info(pdev); glue_info = get_glue_info(&pdev->dev);
if (!glue_info) if (!glue_info)
return -EINVAL; return -EINVAL;
...@@ -970,11 +970,11 @@ static int cppi41_dma_probe(struct platform_device *pdev) ...@@ -970,11 +970,11 @@ static int cppi41_dma_probe(struct platform_device *pdev)
cdd->queues_tx = glue_info->queues_tx; cdd->queues_tx = glue_info->queues_tx;
cdd->td_queue = glue_info->td_queue; cdd->td_queue = glue_info->td_queue;
ret = init_cppi41(pdev, cdd); ret = init_cppi41(&pdev->dev, cdd);
if (ret) if (ret)
goto err_init_cppi; goto err_init_cppi;
ret = cppi41_add_chans(pdev, cdd); ret = cppi41_add_chans(&pdev->dev, cdd);
if (ret) if (ret)
goto err_chans; goto err_chans;
...@@ -1009,7 +1009,7 @@ static int cppi41_dma_probe(struct platform_device *pdev) ...@@ -1009,7 +1009,7 @@ static int cppi41_dma_probe(struct platform_device *pdev)
cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR); cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR);
cleanup_chans(cdd); cleanup_chans(cdd);
err_chans: err_chans:
deinit_cpii41(pdev, cdd); deinit_cpii41(&pdev->dev, cdd);
err_init_cppi: err_init_cppi:
pm_runtime_put(&pdev->dev); pm_runtime_put(&pdev->dev);
err_get_sync: err_get_sync:
...@@ -1033,7 +1033,7 @@ static int cppi41_dma_remove(struct platform_device *pdev) ...@@ -1033,7 +1033,7 @@ static int cppi41_dma_remove(struct platform_device *pdev)
cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR); cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR);
free_irq(cdd->irq, cdd); free_irq(cdd->irq, cdd);
cleanup_chans(cdd); cleanup_chans(cdd);
deinit_cpii41(pdev, cdd); deinit_cpii41(&pdev->dev, cdd);
iounmap(cdd->usbss_mem); iounmap(cdd->usbss_mem);
iounmap(cdd->ctrl_mem); iounmap(cdd->ctrl_mem);
iounmap(cdd->sched_mem); iounmap(cdd->sched_mem);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment