Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

[PATCH] mtd onenand driver: reduce stack usage

Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Kyungmin Park and committed by
Linus Torvalds
532a37cf 20ba89a3

+28 -7
+24 -3
drivers/mtd/onenand/onenand_base.c
··· 940 940 u_char *eccbuf, struct nand_oobinfo *oobsel) 941 941 { 942 942 struct onenand_chip *this = mtd->priv; 943 - unsigned char buffer[MAX_ONENAND_PAGESIZE], *pbuf; 943 + unsigned char *pbuf; 944 944 size_t total_len, len; 945 945 int i, written = 0; 946 946 int ret = 0; ··· 975 975 /* Loop until all keve's data has been written */ 976 976 len = 0; 977 977 while (count) { 978 - pbuf = buffer; 978 + pbuf = this->page_buf; 979 979 /* 980 980 * If the given tuple is >= pagesize then 981 981 * write it out from the iov ··· 995 995 int cnt = 0, thislen; 996 996 while (cnt < mtd->oobblock) { 997 997 thislen = min_t(int, mtd->oobblock - cnt, vecs->iov_len - len); 998 - memcpy(buffer + cnt, vecs->iov_base + len, thislen); 998 + memcpy(this->page_buf + cnt, vecs->iov_base + len, thislen); 999 999 cnt += thislen; 1000 1000 len += thislen; 1001 1001 ··· 1519 1519 this->read_bufferram = onenand_sync_read_bufferram; 1520 1520 } 1521 1521 1522 + /* Allocate buffers, if necessary */ 1523 + if (!this->page_buf) { 1524 + size_t len; 1525 + len = mtd->oobblock + mtd->oobsize; 1526 + this->page_buf = kmalloc(len, GFP_KERNEL); 1527 + if (!this->page_buf) { 1528 + printk(KERN_ERR "onenand_scan(): Can't allocate page_buf\n"); 1529 + return -ENOMEM; 1530 + } 1531 + this->options |= ONENAND_PAGEBUF_ALLOC; 1532 + } 1533 + 1522 1534 this->state = FL_READY; 1523 1535 init_waitqueue_head(&this->wq); 1524 1536 spin_lock_init(&this->chip_lock); ··· 1592 1580 */ 1593 1581 void onenand_release(struct mtd_info *mtd) 1594 1582 { 1583 + struct onenand_chip *this = mtd->priv; 1584 + 1595 1585 #ifdef CONFIG_MTD_PARTITIONS 1596 1586 /* Deregister partitions */ 1597 1587 del_mtd_partitions (mtd); 1598 1588 #endif 1599 1589 /* Deregister the device */ 1600 1590 del_mtd_device (mtd); 1591 + 1592 + /* Free bad block table memory, if allocated */ 1593 + if (this->bbm) 1594 + kfree(this->bbm); 1595 + /* Buffer allocated by onenand_scan */ 1596 + if (this->options & ONENAND_PAGEBUF_ALLOC) 1597 + kfree(this->page_buf); 1601 1598 } 1602 1599 1603 1600 EXPORT_SYMBOL_GPL(onenand_scan);
+2 -2
drivers/mtd/onenand/onenand_bbt.c
··· 118 118 */ 119 119 static inline int onenand_memory_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd) 120 120 { 121 - unsigned char data_buf[MAX_ONENAND_PAGESIZE]; 121 + struct onenand_chip *this = mtd->priv; 122 122 123 123 bd->options &= ~NAND_BBT_SCANEMPTY; 124 - return create_bbt(mtd, data_buf, bd, -1); 124 + return create_bbt(mtd, this->page_buf, bd, -1); 125 125 } 126 126 127 127 /**
+2 -2
include/linux/mtd/onenand.h
··· 17 17 #include <linux/mtd/bbm.h> 18 18 19 19 #define MAX_BUFFERRAM 2 20 - #define MAX_ONENAND_PAGESIZE (2048 + 64) 21 20 22 21 /* Scan and identify a OneNAND device */ 23 22 extern int onenand_scan(struct mtd_info *mtd, int max_chips); ··· 109 110 spinlock_t chip_lock; 110 111 wait_queue_head_t wq; 111 112 onenand_state_t state; 113 + unsigned char *page_buf; 112 114 113 115 struct nand_oobinfo *autooob; 114 116 ··· 134 134 * Options bits 135 135 */ 136 136 #define ONENAND_CONT_LOCK (0x0001) 137 - 137 + #define ONENAND_PAGEBUF_ALLOC (0x1000) 138 138 139 139 /* 140 140 * OneNAND Flash Manufacturer ID Codes