diff options
author | Daniel Mack <zonque@gmail.com> | 2013-09-22 10:50:00 -0400 |
---|---|---|
committer | Vinod Koul <vinod.koul@intel.com> | 2013-10-06 22:11:39 -0400 |
commit | e327e21fb2099119c21e0b9ff7ee0847c19a6735 (patch) | |
tree | dd1ef0c990979bdd0dd7f0649a3b639e7ab09297 /drivers/dma/cppi41.c | |
parent | 404ff6694aae1e89672f3d79d9a5a4f0ba6180f8 (diff) |
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: Daniel Mack <zonque@gmail.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Diffstat (limited to 'drivers/dma/cppi41.c')
-rw-r--r-- | drivers/dma/cppi41.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c index 7c82b92f9b16..53d1d3115575 100644 --- a/drivers/dma/cppi41.c +++ b/drivers/dma/cppi41.c | |||
@@ -674,14 +674,14 @@ static void cleanup_chans(struct cppi41_dd *cdd) | |||
674 | } | 674 | } |
675 | } | 675 | } |
676 | 676 | ||
677 | static int cppi41_add_chans(struct platform_device *pdev, struct cppi41_dd *cdd) | 677 | static int cppi41_add_chans(struct device *dev, struct cppi41_dd *cdd) |
678 | { | 678 | { |
679 | struct cppi41_channel *cchan; | 679 | struct cppi41_channel *cchan; |
680 | int i; | 680 | int i; |
681 | int ret; | 681 | int ret; |
682 | u32 n_chans; | 682 | u32 n_chans; |
683 | 683 | ||
684 | ret = of_property_read_u32(pdev->dev.of_node, "#dma-channels", | 684 | ret = of_property_read_u32(dev->of_node, "#dma-channels", |
685 | &n_chans); | 685 | &n_chans); |
686 | if (ret) | 686 | if (ret) |
687 | return ret; | 687 | return ret; |
@@ -719,7 +719,7 @@ err: | |||
719 | return -ENOMEM; | 719 | return -ENOMEM; |
720 | } | 720 | } |
721 | 721 | ||
722 | static void purge_descs(struct platform_device *pdev, struct cppi41_dd *cdd) | 722 | static void purge_descs(struct device *dev, struct cppi41_dd *cdd) |
723 | { | 723 | { |
724 | unsigned int mem_decs; | 724 | unsigned int mem_decs; |
725 | int i; | 725 | int i; |
@@ -731,7 +731,7 @@ static void purge_descs(struct platform_device *pdev, struct cppi41_dd *cdd) | |||
731 | cppi_writel(0, cdd->qmgr_mem + QMGR_MEMBASE(i)); | 731 | cppi_writel(0, cdd->qmgr_mem + QMGR_MEMBASE(i)); |
732 | cppi_writel(0, cdd->qmgr_mem + QMGR_MEMCTRL(i)); | 732 | cppi_writel(0, cdd->qmgr_mem + QMGR_MEMCTRL(i)); |
733 | 733 | ||
734 | dma_free_coherent(&pdev->dev, mem_decs, cdd->cd, | 734 | dma_free_coherent(dev, mem_decs, cdd->cd, |
735 | cdd->descs_phys); | 735 | cdd->descs_phys); |
736 | } | 736 | } |
737 | } | 737 | } |
@@ -741,19 +741,19 @@ static void disable_sched(struct cppi41_dd *cdd) | |||
741 | cppi_writel(0, cdd->sched_mem + DMA_SCHED_CTRL); | 741 | cppi_writel(0, cdd->sched_mem + DMA_SCHED_CTRL); |
742 | } | 742 | } |
743 | 743 | ||
744 | static void deinit_cpii41(struct platform_device *pdev, struct cppi41_dd *cdd) | 744 | static void deinit_cpii41(struct device *dev, struct cppi41_dd *cdd) |
745 | { | 745 | { |
746 | disable_sched(cdd); | 746 | disable_sched(cdd); |
747 | 747 | ||
748 | purge_descs(pdev, cdd); | 748 | purge_descs(dev, cdd); |
749 | 749 | ||
750 | cppi_writel(0, cdd->qmgr_mem + QMGR_LRAM0_BASE); | 750 | cppi_writel(0, cdd->qmgr_mem + QMGR_LRAM0_BASE); |
751 | cppi_writel(0, cdd->qmgr_mem + QMGR_LRAM0_BASE); | 751 | cppi_writel(0, cdd->qmgr_mem + QMGR_LRAM0_BASE); |
752 | dma_free_coherent(&pdev->dev, QMGR_SCRATCH_SIZE, cdd->qmgr_scratch, | 752 | dma_free_coherent(dev, QMGR_SCRATCH_SIZE, cdd->qmgr_scratch, |
753 | cdd->scratch_phys); | 753 | cdd->scratch_phys); |
754 | } | 754 | } |
755 | 755 | ||
756 | static int init_descs(struct platform_device *pdev, struct cppi41_dd *cdd) | 756 | static int init_descs(struct device *dev, struct cppi41_dd *cdd) |
757 | { | 757 | { |
758 | unsigned int desc_size; | 758 | unsigned int desc_size; |
759 | unsigned int mem_decs; | 759 | unsigned int mem_decs; |
@@ -777,7 +777,7 @@ static int init_descs(struct platform_device *pdev, struct cppi41_dd *cdd) | |||
777 | reg |= ilog2(ALLOC_DECS_NUM) - 5; | 777 | reg |= ilog2(ALLOC_DECS_NUM) - 5; |
778 | 778 | ||
779 | BUILD_BUG_ON(DESCS_AREAS != 1); | 779 | BUILD_BUG_ON(DESCS_AREAS != 1); |
780 | cdd->cd = dma_alloc_coherent(&pdev->dev, mem_decs, | 780 | cdd->cd = dma_alloc_coherent(dev, mem_decs, |
781 | &cdd->descs_phys, GFP_KERNEL); | 781 | &cdd->descs_phys, GFP_KERNEL); |
782 | if (!cdd->cd) | 782 | if (!cdd->cd) |
783 | return -ENOMEM; | 783 | return -ENOMEM; |
@@ -813,12 +813,12 @@ static void init_sched(struct cppi41_dd *cdd) | |||
813 | cppi_writel(reg, cdd->sched_mem + DMA_SCHED_CTRL); | 813 | cppi_writel(reg, cdd->sched_mem + DMA_SCHED_CTRL); |
814 | } | 814 | } |
815 | 815 | ||
816 | static int init_cppi41(struct platform_device *pdev, struct cppi41_dd *cdd) | 816 | static int init_cppi41(struct device *dev, struct cppi41_dd *cdd) |
817 | { | 817 | { |
818 | int ret; | 818 | int ret; |
819 | 819 | ||
820 | BUILD_BUG_ON(QMGR_SCRATCH_SIZE > ((1 << 14) - 1)); | 820 | BUILD_BUG_ON(QMGR_SCRATCH_SIZE > ((1 << 14) - 1)); |
821 | cdd->qmgr_scratch = dma_alloc_coherent(&pdev->dev, QMGR_SCRATCH_SIZE, | 821 | cdd->qmgr_scratch = dma_alloc_coherent(dev, QMGR_SCRATCH_SIZE, |
822 | &cdd->scratch_phys, GFP_KERNEL); | 822 | &cdd->scratch_phys, GFP_KERNEL); |
823 | if (!cdd->qmgr_scratch) | 823 | if (!cdd->qmgr_scratch) |
824 | return -ENOMEM; | 824 | return -ENOMEM; |
@@ -827,7 +827,7 @@ static int init_cppi41(struct platform_device *pdev, struct cppi41_dd *cdd) | |||
827 | cppi_writel(QMGR_SCRATCH_SIZE, cdd->qmgr_mem + QMGR_LRAM_SIZE); | 827 | cppi_writel(QMGR_SCRATCH_SIZE, cdd->qmgr_mem + QMGR_LRAM_SIZE); |
828 | cppi_writel(0, cdd->qmgr_mem + QMGR_LRAM1_BASE); | 828 | cppi_writel(0, cdd->qmgr_mem + QMGR_LRAM1_BASE); |
829 | 829 | ||
830 | ret = init_descs(pdev, cdd); | 830 | ret = init_descs(dev, cdd); |
831 | if (ret) | 831 | if (ret) |
832 | goto err_td; | 832 | goto err_td; |
833 | 833 | ||
@@ -835,7 +835,7 @@ static int init_cppi41(struct platform_device *pdev, struct cppi41_dd *cdd) | |||
835 | init_sched(cdd); | 835 | init_sched(cdd); |
836 | return 0; | 836 | return 0; |
837 | err_td: | 837 | err_td: |
838 | deinit_cpii41(pdev, cdd); | 838 | deinit_cpii41(dev, cdd); |
839 | return ret; | 839 | return ret; |
840 | } | 840 | } |
841 | 841 | ||
@@ -914,11 +914,11 @@ static const struct of_device_id cppi41_dma_ids[] = { | |||
914 | }; | 914 | }; |
915 | MODULE_DEVICE_TABLE(of, cppi41_dma_ids); | 915 | MODULE_DEVICE_TABLE(of, cppi41_dma_ids); |
916 | 916 | ||
917 | static const struct cppi_glue_infos *get_glue_info(struct platform_device *pdev) | 917 | static const struct cppi_glue_infos *get_glue_info(struct device *dev) |
918 | { | 918 | { |
919 | const struct of_device_id *of_id; | 919 | const struct of_device_id *of_id; |
920 | 920 | ||
921 | of_id = of_match_node(cppi41_dma_ids, pdev->dev.of_node); | 921 | of_id = of_match_node(cppi41_dma_ids, dev->of_node); |
922 | if (!of_id) | 922 | if (!of_id) |
923 | return NULL; | 923 | return NULL; |
924 | return of_id->data; | 924 | return of_id->data; |
@@ -931,7 +931,7 @@ static int cppi41_dma_probe(struct platform_device *pdev) | |||
931 | int irq; | 931 | int irq; |
932 | int ret; | 932 | int ret; |
933 | 933 | ||
934 | glue_info = get_glue_info(pdev); | 934 | glue_info = get_glue_info(&pdev->dev); |
935 | if (!glue_info) | 935 | if (!glue_info) |
936 | return -EINVAL; | 936 | return -EINVAL; |
937 | 937 | ||
@@ -970,11 +970,11 @@ static int cppi41_dma_probe(struct platform_device *pdev) | |||
970 | cdd->queues_tx = glue_info->queues_tx; | 970 | cdd->queues_tx = glue_info->queues_tx; |
971 | cdd->td_queue = glue_info->td_queue; | 971 | cdd->td_queue = glue_info->td_queue; |
972 | 972 | ||
973 | ret = init_cppi41(pdev, cdd); | 973 | ret = init_cppi41(&pdev->dev, cdd); |
974 | if (ret) | 974 | if (ret) |
975 | goto err_init_cppi; | 975 | goto err_init_cppi; |
976 | 976 | ||
977 | ret = cppi41_add_chans(pdev, cdd); | 977 | ret = cppi41_add_chans(&pdev->dev, cdd); |
978 | if (ret) | 978 | if (ret) |
979 | goto err_chans; | 979 | goto err_chans; |
980 | 980 | ||
@@ -1009,7 +1009,7 @@ err_irq: | |||
1009 | cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR); | 1009 | cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR); |
1010 | cleanup_chans(cdd); | 1010 | cleanup_chans(cdd); |
1011 | err_chans: | 1011 | err_chans: |
1012 | deinit_cpii41(pdev, cdd); | 1012 | deinit_cpii41(&pdev->dev, cdd); |
1013 | err_init_cppi: | 1013 | err_init_cppi: |
1014 | pm_runtime_put(&pdev->dev); | 1014 | pm_runtime_put(&pdev->dev); |
1015 | err_get_sync: | 1015 | err_get_sync: |
@@ -1033,7 +1033,7 @@ static int cppi41_dma_remove(struct platform_device *pdev) | |||
1033 | cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR); | 1033 | cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR); |
1034 | free_irq(cdd->irq, cdd); | 1034 | free_irq(cdd->irq, cdd); |
1035 | cleanup_chans(cdd); | 1035 | cleanup_chans(cdd); |
1036 | deinit_cpii41(pdev, cdd); | 1036 | deinit_cpii41(&pdev->dev, cdd); |
1037 | iounmap(cdd->usbss_mem); | 1037 | iounmap(cdd->usbss_mem); |
1038 | iounmap(cdd->ctrl_mem); | 1038 | iounmap(cdd->ctrl_mem); |
1039 | iounmap(cdd->sched_mem); | 1039 | iounmap(cdd->sched_mem); |