From: Viresh Kumar Date: Wed, 10 Aug 2011 11:42:11 +0000 (+0530) Subject: spi/spi-pl022: Don't allocate more sg than required. X-Git-Tag: v3.3-rc1~63^3~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b181565ee6a0f894bd6a134b9e5bed2966bdf9b3;p=platform%2Fupstream%2Fkernel-adaptation-pc.git spi/spi-pl022: Don't allocate more sg than required. In routine configure_dma(), if transfer->len = PAGE_SIZE, then pages is one more than required. While leads to one more sg getting allocated. This is wrong. Correct this to allocate correct number of sg. Signed-off-by: Viresh Kumar Tested-by: Linus Walleij Signed-off-by: Grant Likely --- diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index 01e9aa4..248674c 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c @@ -1016,7 +1016,7 @@ static int configure_dma(struct pl022 *pl022) dmaengine_slave_config(txchan, &tx_conf); /* Create sglists for the transfers */ - pages = (pl022->cur_transfer->len >> PAGE_SHIFT) + 1; + pages = DIV_ROUND_UP(pl022->cur_transfer->len, PAGE_SIZE); dev_dbg(&pl022->adev->dev, "using %d pages for transfer\n", pages); ret = sg_alloc_table(&pl022->sgt_rx, pages, GFP_ATOMIC);