diff options
author | Kyungmin Park <kyungmin.park@samsung.com> | 2005-12-15 21:17:29 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-12-18 19:28:24 -0500 |
commit | 532a37cf8d05dd1aa5631be836036204b0d2b4a1 (patch) | |
tree | 4eacbc7f92ce372187ebb445976cae93c4d4b2f5 /drivers/mtd | |
parent | 20ba89a3614bbc5d111fd74375e14c577859b2a3 (diff) |
[PATCH] mtd onenand driver: reduce stack usage
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/onenand/onenand_base.c | 27 | ||||
-rw-r--r-- | drivers/mtd/onenand/onenand_bbt.c | 4 |
2 files changed, 26 insertions, 5 deletions
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c index d57afbaaedc4..a53a73fc2a5a 100644 --- a/drivers/mtd/onenand/onenand_base.c +++ b/drivers/mtd/onenand/onenand_base.c | |||
@@ -940,7 +940,7 @@ static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, | |||
940 | u_char *eccbuf, struct nand_oobinfo *oobsel) | 940 | u_char *eccbuf, struct nand_oobinfo *oobsel) |
941 | { | 941 | { |
942 | struct onenand_chip *this = mtd->priv; | 942 | struct onenand_chip *this = mtd->priv; |
943 | unsigned char buffer[MAX_ONENAND_PAGESIZE], *pbuf; | 943 | unsigned char *pbuf; |
944 | size_t total_len, len; | 944 | size_t total_len, len; |
945 | int i, written = 0; | 945 | int i, written = 0; |
946 | int ret = 0; | 946 | int ret = 0; |
@@ -975,7 +975,7 @@ static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, | |||
975 | /* Loop until all keve's data has been written */ | 975 | /* Loop until all keve's data has been written */ |
976 | len = 0; | 976 | len = 0; |
977 | while (count) { | 977 | while (count) { |
978 | pbuf = buffer; | 978 | pbuf = this->page_buf; |
979 | /* | 979 | /* |
980 | * If the given tuple is >= pagesize then | 980 | * If the given tuple is >= pagesize then |
981 | * write it out from the iov | 981 | * write it out from the iov |
@@ -995,7 +995,7 @@ static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, | |||
995 | int cnt = 0, thislen; | 995 | int cnt = 0, thislen; |
996 | while (cnt < mtd->oobblock) { | 996 | while (cnt < mtd->oobblock) { |
997 | thislen = min_t(int, mtd->oobblock - cnt, vecs->iov_len - len); | 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 | cnt += thislen; | 999 | cnt += thislen; |
1000 | len += thislen; | 1000 | len += thislen; |
1001 | 1001 | ||
@@ -1519,6 +1519,18 @@ int onenand_scan(struct mtd_info *mtd, int maxchips) | |||
1519 | this->read_bufferram = onenand_sync_read_bufferram; | 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 | this->state = FL_READY; | 1534 | this->state = FL_READY; |
1523 | init_waitqueue_head(&this->wq); | 1535 | init_waitqueue_head(&this->wq); |
1524 | spin_lock_init(&this->chip_lock); | 1536 | spin_lock_init(&this->chip_lock); |
@@ -1580,12 +1592,21 @@ int onenand_scan(struct mtd_info *mtd, int maxchips) | |||
1580 | */ | 1592 | */ |
1581 | void onenand_release(struct mtd_info *mtd) | 1593 | void onenand_release(struct mtd_info *mtd) |
1582 | { | 1594 | { |
1595 | struct onenand_chip *this = mtd->priv; | ||
1596 | |||
1583 | #ifdef CONFIG_MTD_PARTITIONS | 1597 | #ifdef CONFIG_MTD_PARTITIONS |
1584 | /* Deregister partitions */ | 1598 | /* Deregister partitions */ |
1585 | del_mtd_partitions (mtd); | 1599 | del_mtd_partitions (mtd); |
1586 | #endif | 1600 | #endif |
1587 | /* Deregister the device */ | 1601 | /* Deregister the device */ |
1588 | del_mtd_device (mtd); | 1602 | del_mtd_device (mtd); |
1603 | |||
1604 | /* Free bad block table memory, if allocated */ | ||
1605 | if (this->bbm) | ||
1606 | kfree(this->bbm); | ||
1607 | /* Buffer allocated by onenand_scan */ | ||
1608 | if (this->options & ONENAND_PAGEBUF_ALLOC) | ||
1609 | kfree(this->page_buf); | ||
1589 | } | 1610 | } |
1590 | 1611 | ||
1591 | EXPORT_SYMBOL_GPL(onenand_scan); | 1612 | EXPORT_SYMBOL_GPL(onenand_scan); |
diff --git a/drivers/mtd/onenand/onenand_bbt.c b/drivers/mtd/onenand/onenand_bbt.c index f40190f499e1..4510d3361eaa 100644 --- a/drivers/mtd/onenand/onenand_bbt.c +++ b/drivers/mtd/onenand/onenand_bbt.c | |||
@@ -118,10 +118,10 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr | |||
118 | */ | 118 | */ |
119 | static inline int onenand_memory_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd) | 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 | bd->options &= ~NAND_BBT_SCANEMPTY; | 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 | /** |