diff options
Diffstat (limited to 'drivers/dma/amba-pl08x.c')
-rw-r--r-- | drivers/dma/amba-pl08x.c | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c index 760b71eec84c..fa78697790c0 100644 --- a/drivers/dma/amba-pl08x.c +++ b/drivers/dma/amba-pl08x.c | |||
@@ -342,7 +342,7 @@ static u32 pl08x_getbytes_chan(struct pl08x_dma_chan *plchan) | |||
342 | struct pl08x_txd *txdi = NULL; | 342 | struct pl08x_txd *txdi = NULL; |
343 | struct pl08x_txd *txd; | 343 | struct pl08x_txd *txd; |
344 | unsigned long flags; | 344 | unsigned long flags; |
345 | u32 bytes = 0; | 345 | size_t bytes = 0; |
346 | 346 | ||
347 | spin_lock_irqsave(&plchan->lock, flags); | 347 | spin_lock_irqsave(&plchan->lock, flags); |
348 | 348 | ||
@@ -470,7 +470,7 @@ static inline unsigned int pl08x_get_bytes_for_cctl(unsigned int coded) | |||
470 | } | 470 | } |
471 | 471 | ||
472 | static inline u32 pl08x_cctl_bits(u32 cctl, u8 srcwidth, u8 dstwidth, | 472 | static inline u32 pl08x_cctl_bits(u32 cctl, u8 srcwidth, u8 dstwidth, |
473 | u32 tsize) | 473 | size_t tsize) |
474 | { | 474 | { |
475 | u32 retbits = cctl; | 475 | u32 retbits = cctl; |
476 | 476 | ||
@@ -583,6 +583,8 @@ static int pl08x_fill_lli_for_desc(struct pl08x_driver_data *pl08x, | |||
583 | if (cctl & PL080_CONTROL_DST_INCR) | 583 | if (cctl & PL080_CONTROL_DST_INCR) |
584 | txd->dstbus.addr += len; | 584 | txd->dstbus.addr += len; |
585 | 585 | ||
586 | BUG_ON(*remainder < len); | ||
587 | |||
586 | *remainder -= len; | 588 | *remainder -= len; |
587 | 589 | ||
588 | return num_llis + 1; | 590 | return num_llis + 1; |
@@ -591,7 +593,7 @@ static int pl08x_fill_lli_for_desc(struct pl08x_driver_data *pl08x, | |||
591 | /* | 593 | /* |
592 | * Return number of bytes to fill to boundary, or len | 594 | * Return number of bytes to fill to boundary, or len |
593 | */ | 595 | */ |
594 | static inline u32 pl08x_pre_boundary(u32 addr, u32 len) | 596 | static inline size_t pl08x_pre_boundary(u32 addr, size_t len) |
595 | { | 597 | { |
596 | u32 boundary; | 598 | u32 boundary; |
597 | 599 | ||
@@ -614,11 +616,11 @@ static int pl08x_fill_llis_for_desc(struct pl08x_driver_data *pl08x, | |||
614 | { | 616 | { |
615 | struct pl08x_channel_data *cd = txd->cd; | 617 | struct pl08x_channel_data *cd = txd->cd; |
616 | struct pl08x_bus_data *mbus, *sbus; | 618 | struct pl08x_bus_data *mbus, *sbus; |
617 | u32 remainder; | 619 | size_t remainder; |
618 | int num_llis = 0; | 620 | int num_llis = 0; |
619 | u32 cctl; | 621 | u32 cctl; |
620 | int max_bytes_per_lli; | 622 | size_t max_bytes_per_lli; |
621 | int total_bytes = 0; | 623 | size_t total_bytes = 0; |
622 | struct pl08x_lli *llis_va; | 624 | struct pl08x_lli *llis_va; |
623 | 625 | ||
624 | txd->llis_va = dma_pool_alloc(pl08x->pool, GFP_NOWAIT, | 626 | txd->llis_va = dma_pool_alloc(pl08x->pool, GFP_NOWAIT, |
@@ -686,13 +688,13 @@ static int pl08x_fill_llis_for_desc(struct pl08x_driver_data *pl08x, | |||
686 | max_bytes_per_lli = min(txd->srcbus.buswidth, txd->dstbus.buswidth) * | 688 | max_bytes_per_lli = min(txd->srcbus.buswidth, txd->dstbus.buswidth) * |
687 | PL080_CONTROL_TRANSFER_SIZE_MASK; | 689 | PL080_CONTROL_TRANSFER_SIZE_MASK; |
688 | dev_vdbg(&pl08x->adev->dev, | 690 | dev_vdbg(&pl08x->adev->dev, |
689 | "%s max bytes per lli = %d\n", | 691 | "%s max bytes per lli = %zu\n", |
690 | __func__, max_bytes_per_lli); | 692 | __func__, max_bytes_per_lli); |
691 | 693 | ||
692 | /* We need to count this down to zero */ | 694 | /* We need to count this down to zero */ |
693 | remainder = txd->len; | 695 | remainder = txd->len; |
694 | dev_vdbg(&pl08x->adev->dev, | 696 | dev_vdbg(&pl08x->adev->dev, |
695 | "%s remainder = %d\n", | 697 | "%s remainder = %zu\n", |
696 | __func__, remainder); | 698 | __func__, remainder); |
697 | 699 | ||
698 | /* | 700 | /* |
@@ -760,9 +762,7 @@ static int pl08x_fill_llis_for_desc(struct pl08x_driver_data *pl08x, | |||
760 | * width left | 762 | * width left |
761 | */ | 763 | */ |
762 | while (remainder > (mbus->buswidth - 1)) { | 764 | while (remainder > (mbus->buswidth - 1)) { |
763 | int lli_len, target_len; | 765 | size_t lli_len, target_len, tsize, odd_bytes; |
764 | int tsize; | ||
765 | int odd_bytes; | ||
766 | 766 | ||
767 | /* | 767 | /* |
768 | * If enough left try to send max possible, | 768 | * If enough left try to send max possible, |
@@ -805,7 +805,7 @@ static int pl08x_fill_llis_for_desc(struct pl08x_driver_data *pl08x, | |||
805 | 805 | ||
806 | if (lli_len <= 0) { | 806 | if (lli_len <= 0) { |
807 | dev_err(&pl08x->adev->dev, | 807 | dev_err(&pl08x->adev->dev, |
808 | "%s lli_len is %d, <= 0\n", | 808 | "%s lli_len is %zu, <= 0\n", |
809 | __func__, lli_len); | 809 | __func__, lli_len); |
810 | return 0; | 810 | return 0; |
811 | } | 811 | } |
@@ -853,7 +853,7 @@ static int pl08x_fill_llis_for_desc(struct pl08x_driver_data *pl08x, | |||
853 | 853 | ||
854 | if (target_len != lli_len) { | 854 | if (target_len != lli_len) { |
855 | dev_vdbg(&pl08x->adev->dev, | 855 | dev_vdbg(&pl08x->adev->dev, |
856 | "%s can't send what we want. Desired 0x%08x, lli of 0x%08x bytes in txd of 0x%08x\n", | 856 | "%s can't send what we want. Desired 0x%08zx, lli of 0x%08zx bytes in txd of 0x%08zx\n", |
857 | __func__, target_len, lli_len, txd->len); | 857 | __func__, target_len, lli_len, txd->len); |
858 | } | 858 | } |
859 | 859 | ||
@@ -863,7 +863,7 @@ static int pl08x_fill_llis_for_desc(struct pl08x_driver_data *pl08x, | |||
863 | tsize); | 863 | tsize); |
864 | 864 | ||
865 | dev_vdbg(&pl08x->adev->dev, | 865 | dev_vdbg(&pl08x->adev->dev, |
866 | "%s fill lli with single lli chunk of size 0x%08x (remainder 0x%08x)\n", | 866 | "%s fill lli with single lli chunk of size 0x%08zx (remainder 0x%08zx)\n", |
867 | __func__, lli_len, remainder); | 867 | __func__, lli_len, remainder); |
868 | num_llis = pl08x_fill_lli_for_desc(pl08x, txd, | 868 | num_llis = pl08x_fill_lli_for_desc(pl08x, txd, |
869 | num_llis, lli_len, cctl, | 869 | num_llis, lli_len, cctl, |
@@ -882,7 +882,7 @@ static int pl08x_fill_llis_for_desc(struct pl08x_driver_data *pl08x, | |||
882 | && (remainder); j++) { | 882 | && (remainder); j++) { |
883 | cctl = pl08x_cctl_bits(cctl, 1, 1, 1); | 883 | cctl = pl08x_cctl_bits(cctl, 1, 1, 1); |
884 | dev_vdbg(&pl08x->adev->dev, | 884 | dev_vdbg(&pl08x->adev->dev, |
885 | "%s align with boundary, single byte (remain 0x%08x)\n", | 885 | "%s align with boundary, single byte (remain 0x%08zx)\n", |
886 | __func__, remainder); | 886 | __func__, remainder); |
887 | num_llis = | 887 | num_llis = |
888 | pl08x_fill_lli_for_desc(pl08x, | 888 | pl08x_fill_lli_for_desc(pl08x, |
@@ -896,16 +896,10 @@ static int pl08x_fill_llis_for_desc(struct pl08x_driver_data *pl08x, | |||
896 | /* | 896 | /* |
897 | * Send any odd bytes | 897 | * Send any odd bytes |
898 | */ | 898 | */ |
899 | if (remainder < 0) { | ||
900 | dev_err(&pl08x->adev->dev, "%s remainder not fitted 0x%08x bytes\n", | ||
901 | __func__, remainder); | ||
902 | return 0; | ||
903 | } | ||
904 | |||
905 | while (remainder) { | 899 | while (remainder) { |
906 | cctl = pl08x_cctl_bits(cctl, 1, 1, 1); | 900 | cctl = pl08x_cctl_bits(cctl, 1, 1, 1); |
907 | dev_vdbg(&pl08x->adev->dev, | 901 | dev_vdbg(&pl08x->adev->dev, |
908 | "%s align with boundary, single odd byte (remain %d)\n", | 902 | "%s align with boundary, single odd byte (remain %zu)\n", |
909 | __func__, remainder); | 903 | __func__, remainder); |
910 | num_llis = pl08x_fill_lli_for_desc(pl08x, txd, num_llis, | 904 | num_llis = pl08x_fill_lli_for_desc(pl08x, txd, num_llis, |
911 | 1, cctl, &remainder); | 905 | 1, cctl, &remainder); |
@@ -914,7 +908,7 @@ static int pl08x_fill_llis_for_desc(struct pl08x_driver_data *pl08x, | |||
914 | } | 908 | } |
915 | if (total_bytes != txd->len) { | 909 | if (total_bytes != txd->len) { |
916 | dev_err(&pl08x->adev->dev, | 910 | dev_err(&pl08x->adev->dev, |
917 | "%s size of encoded lli:s don't match total txd, transferred 0x%08x from size 0x%08x\n", | 911 | "%s size of encoded lli:s don't match total txd, transferred 0x%08zx from size 0x%08zx\n", |
918 | __func__, total_bytes, txd->len); | 912 | __func__, total_bytes, txd->len); |
919 | return 0; | 913 | return 0; |
920 | } | 914 | } |