Skip to content

Commit 1c38b28

Browse files
Andre PrzywaraRob Herring
Andre Przywara
authored and
Rob Herring
committedAug 23, 2013
DMA: fix AMBA PL08x compilation issue with 64bit DMA address type
When dma_addr_t is 64 bits long, compilation of the AMBA PL08x DMA driver breaks due to a missing 64bit%8bit modulo operation. Looking more closely the divisor in these operations can only be 1, 2 or 4, so the full featured '%' modulo operation is overkill and can be replaced with simple bit masking. Change from v1: Replace open-coded function with existing IS_ALIGNED macro and use a macro around that to avoid a line becoming too long. Signed-off-by: Andre Przywara <[email protected]> Acked-by: Vinod Koul <[email protected]> Signed-off-by: Rob Herring <[email protected]>
1 parent 2c63494 commit 1c38b28

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed
 

‎drivers/dma/amba-pl08x.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ struct pl08x_bus_data {
133133
u8 buswidth;
134134
};
135135

136+
#define IS_BUS_ALIGNED(bus) IS_ALIGNED((bus)->addr, (bus)->buswidth)
137+
136138
/**
137139
* struct pl08x_phy_chan - holder for the physical channels
138140
* @id: physical index to this channel
@@ -886,8 +888,8 @@ static int pl08x_fill_llis_for_desc(struct pl08x_driver_data *pl08x,
886888
return 0;
887889
}
888890

889-
if ((bd.srcbus.addr % bd.srcbus.buswidth) ||
890-
(bd.dstbus.addr % bd.dstbus.buswidth)) {
891+
if (!IS_BUS_ALIGNED(&bd.srcbus) ||
892+
!IS_BUS_ALIGNED(&bd.dstbus)) {
891893
dev_err(&pl08x->adev->dev,
892894
"%s src & dst address must be aligned to src"
893895
" & dst width if peripheral is flow controller",
@@ -908,9 +910,9 @@ static int pl08x_fill_llis_for_desc(struct pl08x_driver_data *pl08x,
908910
*/
909911
if (bd.remainder < mbus->buswidth)
910912
early_bytes = bd.remainder;
911-
else if ((mbus->addr) % (mbus->buswidth)) {
912-
early_bytes = mbus->buswidth - (mbus->addr) %
913-
(mbus->buswidth);
913+
else if (!IS_BUS_ALIGNED(mbus)) {
914+
early_bytes = mbus->buswidth -
915+
(mbus->addr & (mbus->buswidth - 1));
914916
if ((bd.remainder - early_bytes) < mbus->buswidth)
915917
early_bytes = bd.remainder;
916918
}
@@ -928,7 +930,7 @@ static int pl08x_fill_llis_for_desc(struct pl08x_driver_data *pl08x,
928930
* Master now aligned
929931
* - if slave is not then we must set its width down
930932
*/
931-
if (sbus->addr % sbus->buswidth) {
933+
if (!IS_BUS_ALIGNED(sbus)) {
932934
dev_dbg(&pl08x->adev->dev,
933935
"%s set down bus width to one byte\n",
934936
__func__);

0 commit comments

Comments
 (0)
Please sign in to comment.