Skip to content

Commit

Permalink
Merge git://git.infradead.org/mtd-2.6
Browse files Browse the repository at this point in the history
* git://git.infradead.org/mtd-2.6:
  mtd: atmel_nand: use CPU I/O when buffer is in vmalloc(ed) region
  mtd: atmel_nand: modify test case for using DMA operations
  mtd: atmel_nand: fix support for CPUs that do not support DMA access
  mtd: atmel_nand: trivial: change DMA usage information trace
  mtd: mtdswap: fix printk format warning
  • Loading branch information
Linus Torvalds committed Apr 9, 2011
2 parents 94c8a98 + 80b4f81 commit 510ec7b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
2 changes: 1 addition & 1 deletion drivers/mtd/mtdswap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1452,7 +1452,7 @@ static void mtdswap_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
oinfo = mtd->ecclayout;
if (!mtd->oobsize || !oinfo || oinfo->oobavail < MTDSWAP_OOBSIZE) {
printk(KERN_ERR "%s: Not enough free bytes in OOB, "
"%d available, %lu needed.\n",
"%d available, %zu needed.\n",
MTDSWAP_PREFIX, oinfo->oobavail, MTDSWAP_OOBSIZE);
return;
}
Expand Down
32 changes: 12 additions & 20 deletions drivers/mtd/nand/atmel_nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,22 +209,8 @@ static int atmel_nand_dma_op(struct mtd_info *mtd, void *buf, int len,
int err = -EIO;
enum dma_data_direction dir = is_read ? DMA_FROM_DEVICE : DMA_TO_DEVICE;

if (buf >= high_memory) {
struct page *pg;

if (((size_t)buf & PAGE_MASK) !=
((size_t)(buf + len - 1) & PAGE_MASK)) {
dev_warn(host->dev, "Buffer not fit in one page\n");
goto err_buf;
}

pg = vmalloc_to_page(buf);
if (pg == 0) {
dev_err(host->dev, "Failed to vmalloc_to_page\n");
goto err_buf;
}
p = page_address(pg) + ((size_t)buf & ~PAGE_MASK);
}
if (buf >= high_memory)
goto err_buf;

dma_dev = host->dma_chan->device;

Expand Down Expand Up @@ -280,7 +266,8 @@ static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len)
struct nand_chip *chip = mtd->priv;
struct atmel_nand_host *host = chip->priv;

if (use_dma && len >= mtd->oobsize)
if (use_dma && len > mtd->oobsize)
/* only use DMA for bigger than oob size: better performances */
if (atmel_nand_dma_op(mtd, buf, len, 1) == 0)
return;

Expand All @@ -295,7 +282,8 @@ static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
struct nand_chip *chip = mtd->priv;
struct atmel_nand_host *host = chip->priv;

if (use_dma && len >= mtd->oobsize)
if (use_dma && len > mtd->oobsize)
/* only use DMA for bigger than oob size: better performances */
if (atmel_nand_dma_op(mtd, (void *)buf, len, 0) == 0)
return;

Expand Down Expand Up @@ -599,7 +587,10 @@ static int __init atmel_nand_probe(struct platform_device *pdev)
nand_chip->options |= NAND_USE_FLASH_BBT;
}

if (cpu_has_dma() && use_dma) {
if (!cpu_has_dma())
use_dma = 0;

if (use_dma) {
dma_cap_mask_t mask;

dma_cap_zero(mask);
Expand All @@ -611,7 +602,8 @@ static int __init atmel_nand_probe(struct platform_device *pdev)
}
}
if (use_dma)
dev_info(host->dev, "Using DMA for NAND access.\n");
dev_info(host->dev, "Using %s for DMA transfers.\n",
dma_chan_name(host->dma_chan));
else
dev_info(host->dev, "No DMA support for NAND access.\n");

Expand Down

0 comments on commit 510ec7b

Please sign in to comment.