aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c146
-rw-r--r--drivers/mtd/nand/Kconfig2
-rw-r--r--drivers/mtd/nand/diskonchip.c4
-rw-r--r--drivers/mtd/nand/nand_base.c6
-rw-r--r--drivers/mtd/nand/nand_ecc.c2
-rw-r--r--drivers/mtd/nand/nandsim.c2
-rw-r--r--drivers/mtd/nand/s3c2410.c14
-rw-r--r--drivers/mtd/onenand/onenand_sim.c50
-rw-r--r--fs/jffs2/acl.c101
-rw-r--r--fs/jffs2/acl.h12
-rw-r--r--fs/jffs2/dir.c35
-rw-r--r--fs/jffs2/file.c11
-rw-r--r--fs/jffs2/fs.c21
-rw-r--r--fs/jffs2/os-linux.h4
-rw-r--r--fs/jffs2/write.c8
-rw-r--r--lib/reed_solomon/decode_rs.c5
-rw-r--r--lib/reed_solomon/reed_solomon.c2
17 files changed, 226 insertions, 199 deletions
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index 3aa3dca56ae6..a9eb1c516247 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -85,6 +85,7 @@ static int cfi_intelext_point (struct mtd_info *mtd, loff_t from, size_t len,
85static void cfi_intelext_unpoint (struct mtd_info *mtd, u_char *addr, loff_t from, 85static void cfi_intelext_unpoint (struct mtd_info *mtd, u_char *addr, loff_t from,
86 size_t len); 86 size_t len);
87 87
88static int chip_ready (struct map_info *map, struct flchip *chip, unsigned long adr, int mode);
88static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode); 89static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode);
89static void put_chip(struct map_info *map, struct flchip *chip, unsigned long adr); 90static void put_chip(struct map_info *map, struct flchip *chip, unsigned long adr);
90#include "fwh_lock.h" 91#include "fwh_lock.h"
@@ -641,73 +642,13 @@ static int cfi_intelext_partition_fixup(struct mtd_info *mtd,
641/* 642/*
642 * *********** CHIP ACCESS FUNCTIONS *********** 643 * *********** CHIP ACCESS FUNCTIONS ***********
643 */ 644 */
644 645static int chip_ready (struct map_info *map, struct flchip *chip, unsigned long adr, int mode)
645static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode)
646{ 646{
647 DECLARE_WAITQUEUE(wait, current); 647 DECLARE_WAITQUEUE(wait, current);
648 struct cfi_private *cfi = map->fldrv_priv; 648 struct cfi_private *cfi = map->fldrv_priv;
649 map_word status, status_OK = CMD(0x80), status_PWS = CMD(0x01); 649 map_word status, status_OK = CMD(0x80), status_PWS = CMD(0x01);
650 unsigned long timeo;
651 struct cfi_pri_intelext *cfip = cfi->cmdset_priv; 650 struct cfi_pri_intelext *cfip = cfi->cmdset_priv;
652 651 unsigned long timeo = jiffies + HZ;
653 resettime:
654 timeo = jiffies + HZ;
655 retry:
656 if (chip->priv && (mode == FL_WRITING || mode == FL_ERASING || mode == FL_OTP_WRITE || mode == FL_SHUTDOWN)) {
657 /*
658 * OK. We have possibility for contension on the write/erase
659 * operations which are global to the real chip and not per
660 * partition. So let's fight it over in the partition which
661 * currently has authority on the operation.
662 *
663 * The rules are as follows:
664 *
665 * - any write operation must own shared->writing.
666 *
667 * - any erase operation must own _both_ shared->writing and
668 * shared->erasing.
669 *
670 * - contension arbitration is handled in the owner's context.
671 *
672 * The 'shared' struct can be read and/or written only when
673 * its lock is taken.
674 */
675 struct flchip_shared *shared = chip->priv;
676 struct flchip *contender;
677 spin_lock(&shared->lock);
678 contender = shared->writing;
679 if (contender && contender != chip) {
680 /*
681 * The engine to perform desired operation on this
682 * partition is already in use by someone else.
683 * Let's fight over it in the context of the chip
684 * currently using it. If it is possible to suspend,
685 * that other partition will do just that, otherwise
686 * it'll happily send us to sleep. In any case, when
687 * get_chip returns success we're clear to go ahead.
688 */
689 int ret = spin_trylock(contender->mutex);
690 spin_unlock(&shared->lock);
691 if (!ret)
692 goto retry;
693 spin_unlock(chip->mutex);
694 ret = get_chip(map, contender, contender->start, mode);
695 spin_lock(chip->mutex);
696 if (ret) {
697 spin_unlock(contender->mutex);
698 return ret;
699 }
700 timeo = jiffies + HZ;
701 spin_lock(&shared->lock);
702 spin_unlock(contender->mutex);
703 }
704
705 /* We now own it */
706 shared->writing = chip;
707 if (mode == FL_ERASING)
708 shared->erasing = chip;
709 spin_unlock(&shared->lock);
710 }
711 652
712 switch (chip->state) { 653 switch (chip->state) {
713 654
@@ -722,16 +663,11 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
722 if (chip->priv && map_word_andequal(map, status, status_PWS, status_PWS)) 663 if (chip->priv && map_word_andequal(map, status, status_PWS, status_PWS))
723 break; 664 break;
724 665
725 if (time_after(jiffies, timeo)) {
726 printk(KERN_ERR "%s: Waiting for chip to be ready timed out. Status %lx\n",
727 map->name, status.x[0]);
728 return -EIO;
729 }
730 spin_unlock(chip->mutex); 666 spin_unlock(chip->mutex);
731 cfi_udelay(1); 667 cfi_udelay(1);
732 spin_lock(chip->mutex); 668 spin_lock(chip->mutex);
733 /* Someone else might have been playing with it. */ 669 /* Someone else might have been playing with it. */
734 goto retry; 670 return -EAGAIN;
735 } 671 }
736 672
737 case FL_READY: 673 case FL_READY:
@@ -809,10 +745,82 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
809 schedule(); 745 schedule();
810 remove_wait_queue(&chip->wq, &wait); 746 remove_wait_queue(&chip->wq, &wait);
811 spin_lock(chip->mutex); 747 spin_lock(chip->mutex);
812 goto resettime; 748 return -EAGAIN;
813 } 749 }
814} 750}
815 751
752static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode)
753{
754 int ret;
755
756 retry:
757 if (chip->priv && (mode == FL_WRITING || mode == FL_ERASING
758 || mode == FL_OTP_WRITE || mode == FL_SHUTDOWN)) {
759 /*
760 * OK. We have possibility for contention on the write/erase
761 * operations which are global to the real chip and not per
762 * partition. So let's fight it over in the partition which
763 * currently has authority on the operation.
764 *
765 * The rules are as follows:
766 *
767 * - any write operation must own shared->writing.
768 *
769 * - any erase operation must own _both_ shared->writing and
770 * shared->erasing.
771 *
772 * - contention arbitration is handled in the owner's context.
773 *
774 * The 'shared' struct can be read and/or written only when
775 * its lock is taken.
776 */
777 struct flchip_shared *shared = chip->priv;
778 struct flchip *contender;
779 spin_lock(&shared->lock);
780 contender = shared->writing;
781 if (contender && contender != chip) {
782 /*
783 * The engine to perform desired operation on this
784 * partition is already in use by someone else.
785 * Let's fight over it in the context of the chip
786 * currently using it. If it is possible to suspend,
787 * that other partition will do just that, otherwise
788 * it'll happily send us to sleep. In any case, when
789 * get_chip returns success we're clear to go ahead.
790 */
791 ret = spin_trylock(contender->mutex);
792 spin_unlock(&shared->lock);
793 if (!ret)
794 goto retry;
795 spin_unlock(chip->mutex);
796 ret = chip_ready(map, contender, contender->start, mode);
797 spin_lock(chip->mutex);
798
799 if (ret == -EAGAIN) {
800 spin_unlock(contender->mutex);
801 goto retry;
802 }
803 if (ret) {
804 spin_unlock(contender->mutex);
805 return ret;
806 }
807 spin_lock(&shared->lock);
808 spin_unlock(contender->mutex);
809 }
810
811 /* We now own it */
812 shared->writing = chip;
813 if (mode == FL_ERASING)
814 shared->erasing = chip;
815 spin_unlock(&shared->lock);
816 }
817 ret = chip_ready(map, chip, adr, mode);
818 if (ret == -EAGAIN)
819 goto retry;
820
821 return ret;
822}
823
816static void put_chip(struct map_info *map, struct flchip *chip, unsigned long adr) 824static void put_chip(struct map_info *map, struct flchip *chip, unsigned long adr)
817{ 825{
818 struct cfi_private *cfi = map->fldrv_priv; 826 struct cfi_private *cfi = map->fldrv_priv;
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 8f9c3baeb38e..246d4512f64b 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -300,7 +300,7 @@ config MTD_NAND_PLATFORM
300 via platform_data. 300 via platform_data.
301 301
302config MTD_ALAUDA 302config MTD_ALAUDA
303 tristate "MTD driver for Olympus MAUSB-10 and Fijufilm DPC-R1" 303 tristate "MTD driver for Olympus MAUSB-10 and Fujifilm DPC-R1"
304 depends on MTD_NAND && USB 304 depends on MTD_NAND && USB
305 help 305 help
306 These two (and possibly other) Alauda-based cardreaders for 306 These two (and possibly other) Alauda-based cardreaders for
diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c
index ab9f5c5db38d..0e72153b3297 100644
--- a/drivers/mtd/nand/diskonchip.c
+++ b/drivers/mtd/nand/diskonchip.c
@@ -220,7 +220,7 @@ static int doc_ecc_decode(struct rs_control *rs, uint8_t *data, uint8_t *ecc)
220 } 220 }
221 } 221 }
222 /* If the parity is wrong, no rescue possible */ 222 /* If the parity is wrong, no rescue possible */
223 return parity ? -1 : nerr; 223 return parity ? -EBADMSG : nerr;
224} 224}
225 225
226static void DoC_Delay(struct doc_priv *doc, unsigned short cycles) 226static void DoC_Delay(struct doc_priv *doc, unsigned short cycles)
@@ -1034,7 +1034,7 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat,
1034 WriteDOC(DOC_ECC_DIS, docptr, Mplus_ECCConf); 1034 WriteDOC(DOC_ECC_DIS, docptr, Mplus_ECCConf);
1035 else 1035 else
1036 WriteDOC(DOC_ECC_DIS, docptr, ECCConf); 1036 WriteDOC(DOC_ECC_DIS, docptr, ECCConf);
1037 if (no_ecc_failures && (ret == -1)) { 1037 if (no_ecc_failures && (ret == -EBADMSG)) {
1038 printk(KERN_ERR "suppressing ECC failure\n"); 1038 printk(KERN_ERR "suppressing ECC failure\n");
1039 ret = 0; 1039 ret = 0;
1040 } 1040 }
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index b4e0e7723894..e29c1da7f56e 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -789,7 +789,7 @@ static int nand_read_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,
789 int stat; 789 int stat;
790 790
791 stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]); 791 stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]);
792 if (stat == -1) 792 if (stat < 0)
793 mtd->ecc_stats.failed++; 793 mtd->ecc_stats.failed++;
794 else 794 else
795 mtd->ecc_stats.corrected += stat; 795 mtd->ecc_stats.corrected += stat;
@@ -833,7 +833,7 @@ static int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
833 int stat; 833 int stat;
834 834
835 stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]); 835 stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]);
836 if (stat == -1) 836 if (stat < 0)
837 mtd->ecc_stats.failed++; 837 mtd->ecc_stats.failed++;
838 else 838 else
839 mtd->ecc_stats.corrected += stat; 839 mtd->ecc_stats.corrected += stat;
@@ -874,7 +874,7 @@ static int nand_read_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
874 chip->read_buf(mtd, oob, eccbytes); 874 chip->read_buf(mtd, oob, eccbytes);
875 stat = chip->ecc.correct(mtd, p, oob, NULL); 875 stat = chip->ecc.correct(mtd, p, oob, NULL);
876 876
877 if (stat == -1) 877 if (stat < 0)
878 mtd->ecc_stats.failed++; 878 mtd->ecc_stats.failed++;
879 else 879 else
880 mtd->ecc_stats.corrected += stat; 880 mtd->ecc_stats.corrected += stat;
diff --git a/drivers/mtd/nand/nand_ecc.c b/drivers/mtd/nand/nand_ecc.c
index fde593e5e634..9003a135e050 100644
--- a/drivers/mtd/nand/nand_ecc.c
+++ b/drivers/mtd/nand/nand_ecc.c
@@ -189,7 +189,7 @@ int nand_correct_data(struct mtd_info *mtd, u_char *dat,
189 if(countbits(s0 | ((uint32_t)s1 << 8) | ((uint32_t)s2 <<16)) == 1) 189 if(countbits(s0 | ((uint32_t)s1 << 8) | ((uint32_t)s2 <<16)) == 1)
190 return 1; 190 return 1;
191 191
192 return -1; 192 return -EBADMSG;
193} 193}
194EXPORT_SYMBOL(nand_correct_data); 194EXPORT_SYMBOL(nand_correct_data);
195 195
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index a7574807dc46..10490b48d9f7 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -511,7 +511,7 @@ static int init_nandsim(struct mtd_info *mtd)
511 } 511 }
512 512
513 if (ns->options & OPT_SMALLPAGE) { 513 if (ns->options & OPT_SMALLPAGE) {
514 if (ns->geom.totsz < (64 << 20)) { 514 if (ns->geom.totsz < (32 << 20)) {
515 ns->geom.pgaddrbytes = 3; 515 ns->geom.pgaddrbytes = 3;
516 ns->geom.secaddrbytes = 2; 516 ns->geom.secaddrbytes = 2;
517 } else { 517 } else {
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
index 21b921dd6aab..66f76e9618dd 100644
--- a/drivers/mtd/nand/s3c2410.c
+++ b/drivers/mtd/nand/s3c2410.c
@@ -488,12 +488,24 @@ static void s3c2410_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
488 readsb(this->IO_ADDR_R, buf, len); 488 readsb(this->IO_ADDR_R, buf, len);
489} 489}
490 490
491static void s3c2440_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
492{
493 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
494 readsl(info->regs + S3C2440_NFDATA, buf, len / 4);
495}
496
491static void s3c2410_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len) 497static void s3c2410_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
492{ 498{
493 struct nand_chip *this = mtd->priv; 499 struct nand_chip *this = mtd->priv;
494 writesb(this->IO_ADDR_W, buf, len); 500 writesb(this->IO_ADDR_W, buf, len);
495} 501}
496 502
503static void s3c2440_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
504{
505 struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
506 writesl(info->regs + S3C2440_NFDATA, buf, len / 4);
507}
508
497/* device management functions */ 509/* device management functions */
498 510
499static int s3c2410_nand_remove(struct platform_device *pdev) 511static int s3c2410_nand_remove(struct platform_device *pdev)
@@ -604,6 +616,8 @@ static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info,
604 info->sel_bit = S3C2440_NFCONT_nFCE; 616 info->sel_bit = S3C2440_NFCONT_nFCE;
605 chip->cmd_ctrl = s3c2440_nand_hwcontrol; 617 chip->cmd_ctrl = s3c2440_nand_hwcontrol;
606 chip->dev_ready = s3c2440_nand_devready; 618 chip->dev_ready = s3c2440_nand_devready;
619 chip->read_buf = s3c2440_nand_read_buf;
620 chip->write_buf = s3c2440_nand_write_buf;
607 break; 621 break;
608 622
609 case TYPE_S3C2412: 623 case TYPE_S3C2412:
diff --git a/drivers/mtd/onenand/onenand_sim.c b/drivers/mtd/onenand/onenand_sim.c
index 0d89ad5776fa..d64200b7c94b 100644
--- a/drivers/mtd/onenand/onenand_sim.c
+++ b/drivers/mtd/onenand/onenand_sim.c
@@ -88,11 +88,11 @@ do { \
88 88
89/** 89/**
90 * onenand_lock_handle - Handle Lock scheme 90 * onenand_lock_handle - Handle Lock scheme
91 * @param this OneNAND device structure 91 * @this: OneNAND device structure
92 * @param cmd The command to be sent 92 * @cmd: The command to be sent
93 * 93 *
94 * Send lock command to OneNAND device. 94 * Send lock command to OneNAND device.
95 * The lock scheme is depends on chip type. 95 * The lock scheme depends on chip type.
96 */ 96 */
97static void onenand_lock_handle(struct onenand_chip *this, int cmd) 97static void onenand_lock_handle(struct onenand_chip *this, int cmd)
98{ 98{
@@ -131,8 +131,8 @@ static void onenand_lock_handle(struct onenand_chip *this, int cmd)
131 131
132/** 132/**
133 * onenand_bootram_handle - Handle BootRAM area 133 * onenand_bootram_handle - Handle BootRAM area
134 * @param this OneNAND device structure 134 * @this: OneNAND device structure
135 * @param cmd The command to be sent 135 * @cmd: The command to be sent
136 * 136 *
137 * Emulate BootRAM area. It is possible to do basic operation using BootRAM. 137 * Emulate BootRAM area. It is possible to do basic operation using BootRAM.
138 */ 138 */
@@ -153,10 +153,10 @@ static void onenand_bootram_handle(struct onenand_chip *this, int cmd)
153 153
154/** 154/**
155 * onenand_update_interrupt - Set interrupt register 155 * onenand_update_interrupt - Set interrupt register
156 * @param this OneNAND device structure 156 * @this: OneNAND device structure
157 * @param cmd The command to be sent 157 * @cmd: The command to be sent
158 * 158 *
159 * Update interrupt register. The status is depends on command. 159 * Update interrupt register. The status depends on command.
160 */ 160 */
161static void onenand_update_interrupt(struct onenand_chip *this, int cmd) 161static void onenand_update_interrupt(struct onenand_chip *this, int cmd)
162{ 162{
@@ -189,11 +189,12 @@ static void onenand_update_interrupt(struct onenand_chip *this, int cmd)
189} 189}
190 190
191/** 191/**
192 * onenand_check_overwrite - Check over-write if happend 192 * onenand_check_overwrite - Check if over-write happened
193 * @param dest The destination pointer 193 * @dest: The destination pointer
194 * @param src The source pointer 194 * @src: The source pointer
195 * @param count The length to be check 195 * @count: The length to be check
196 * @return 0 on same, otherwise 1 196 *
197 * Returns: 0 on same, otherwise 1
197 * 198 *
198 * Compare the source with destination 199 * Compare the source with destination
199 */ 200 */
@@ -213,10 +214,10 @@ static int onenand_check_overwrite(void *dest, void *src, size_t count)
213 214
214/** 215/**
215 * onenand_data_handle - Handle OneNAND Core and DataRAM 216 * onenand_data_handle - Handle OneNAND Core and DataRAM
216 * @param this OneNAND device structure 217 * @this: OneNAND device structure
217 * @param cmd The command to be sent 218 * @cmd: The command to be sent
218 * @param dataram Which dataram used 219 * @dataram: Which dataram used
219 * @param offset The offset to OneNAND Core 220 * @offset: The offset to OneNAND Core
220 * 221 *
221 * Copy data from OneNAND Core to DataRAM (read) 222 * Copy data from OneNAND Core to DataRAM (read)
222 * Copy data from DataRAM to OneNAND Core (write) 223 * Copy data from DataRAM to OneNAND Core (write)
@@ -295,8 +296,8 @@ static void onenand_data_handle(struct onenand_chip *this, int cmd,
295 296
296/** 297/**
297 * onenand_command_handle - Handle command 298 * onenand_command_handle - Handle command
298 * @param this OneNAND device structure 299 * @this: OneNAND device structure
299 * @param cmd The command to be sent 300 * @cmd: The command to be sent
300 * 301 *
301 * Emulate OneNAND command. 302 * Emulate OneNAND command.
302 */ 303 */
@@ -350,8 +351,8 @@ static void onenand_command_handle(struct onenand_chip *this, int cmd)
350 351
351/** 352/**
352 * onenand_writew - [OneNAND Interface] Emulate write operation 353 * onenand_writew - [OneNAND Interface] Emulate write operation
353 * @param value value to write 354 * @value: value to write
354 * @param addr address to write 355 * @addr: address to write
355 * 356 *
356 * Write OneNAND register with value 357 * Write OneNAND register with value
357 */ 358 */
@@ -373,7 +374,7 @@ static void onenand_writew(unsigned short value, void __iomem * addr)
373 374
374/** 375/**
375 * flash_init - Initialize OneNAND simulator 376 * flash_init - Initialize OneNAND simulator
376 * @param flash OneNAND simulaotr data strucutres 377 * @flash: OneNAND simulator data strucutres
377 * 378 *
378 * Initialize OneNAND simulator. 379 * Initialize OneNAND simulator.
379 */ 380 */
@@ -416,7 +417,7 @@ static int __init flash_init(struct onenand_flash *flash)
416 417
417/** 418/**
418 * flash_exit - Clean up OneNAND simulator 419 * flash_exit - Clean up OneNAND simulator
419 * @param flash OneNAND simulaotr data strucutres 420 * @flash: OneNAND simulator data structures
420 * 421 *
421 * Clean up OneNAND simulator. 422 * Clean up OneNAND simulator.
422 */ 423 */
@@ -424,7 +425,6 @@ static void flash_exit(struct onenand_flash *flash)
424{ 425{
425 vfree(ONENAND_CORE(flash)); 426 vfree(ONENAND_CORE(flash));
426 kfree(flash->base); 427 kfree(flash->base);
427 kfree(flash);
428} 428}
429 429
430static int __init onenand_sim_init(void) 430static int __init onenand_sim_init(void)
@@ -449,7 +449,7 @@ static int __init onenand_sim_init(void)
449 info->onenand.write_word = onenand_writew; 449 info->onenand.write_word = onenand_writew;
450 450
451 if (flash_init(&info->flash)) { 451 if (flash_init(&info->flash)) {
452 printk(KERN_ERR "Unable to allocat flash.\n"); 452 printk(KERN_ERR "Unable to allocate flash.\n");
453 kfree(ffchars); 453 kfree(ffchars);
454 kfree(info); 454 kfree(info);
455 return -ENOMEM; 455 return -ENOMEM;
diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c
index 8ec9323e830a..9728614b8958 100644
--- a/fs/jffs2/acl.c
+++ b/fs/jffs2/acl.c
@@ -228,11 +228,28 @@ struct posix_acl *jffs2_get_acl(struct inode *inode, int type)
228 return acl; 228 return acl;
229} 229}
230 230
231static int __jffs2_set_acl(struct inode *inode, int xprefix, struct posix_acl *acl)
232{
233 char *value = NULL;
234 size_t size = 0;
235 int rc;
236
237 if (acl) {
238 value = jffs2_acl_to_medium(acl, &size);
239 if (IS_ERR(value))
240 return PTR_ERR(value);
241 }
242 rc = do_jffs2_setxattr(inode, xprefix, "", value, size, 0);
243 if (!value && rc == -ENODATA)
244 rc = 0;
245 kfree(value);
246
247 return rc;
248}
249
231static int jffs2_set_acl(struct inode *inode, int type, struct posix_acl *acl) 250static int jffs2_set_acl(struct inode *inode, int type, struct posix_acl *acl)
232{ 251{
233 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); 252 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
234 size_t size = 0;
235 char *value = NULL;
236 int rc, xprefix; 253 int rc, xprefix;
237 254
238 if (S_ISLNK(inode->i_mode)) 255 if (S_ISLNK(inode->i_mode))
@@ -267,17 +284,7 @@ static int jffs2_set_acl(struct inode *inode, int type, struct posix_acl *acl)
267 default: 284 default:
268 return -EINVAL; 285 return -EINVAL;
269 } 286 }
270 if (acl) { 287 rc = __jffs2_set_acl(inode, xprefix, acl);
271 value = jffs2_acl_to_medium(acl, &size);
272 if (IS_ERR(value))
273 return PTR_ERR(value);
274 }
275
276 rc = do_jffs2_setxattr(inode, xprefix, "", value, size, 0);
277 if (!value && rc == -ENODATA)
278 rc = 0;
279 if (value)
280 kfree(value);
281 if (!rc) { 288 if (!rc) {
282 switch(type) { 289 switch(type) {
283 case ACL_TYPE_ACCESS: 290 case ACL_TYPE_ACCESS:
@@ -312,37 +319,59 @@ int jffs2_permission(struct inode *inode, int mask, struct nameidata *nd)
312 return generic_permission(inode, mask, jffs2_check_acl); 319 return generic_permission(inode, mask, jffs2_check_acl);
313} 320}
314 321
315int jffs2_init_acl(struct inode *inode, struct posix_acl *acl) 322int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, int *i_mode)
316{ 323{
317 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); 324 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
318 struct posix_acl *clone; 325 struct posix_acl *acl, *clone;
319 mode_t mode; 326 int rc;
320 int rc = 0;
321 327
322 f->i_acl_access = JFFS2_ACL_NOT_CACHED; 328 f->i_acl_default = NULL;
323 f->i_acl_default = JFFS2_ACL_NOT_CACHED; 329 f->i_acl_access = NULL;
330
331 if (S_ISLNK(*i_mode))
332 return 0; /* Symlink always has no-ACL */
333
334 acl = jffs2_get_acl(dir_i, ACL_TYPE_DEFAULT);
335 if (IS_ERR(acl))
336 return PTR_ERR(acl);
337
338 if (!acl) {
339 *i_mode &= ~current->fs->umask;
340 } else {
341 if (S_ISDIR(*i_mode))
342 jffs2_iset_acl(inode, &f->i_acl_default, acl);
324 343
325 if (acl) {
326 if (S_ISDIR(inode->i_mode)) {
327 rc = jffs2_set_acl(inode, ACL_TYPE_DEFAULT, acl);
328 if (rc)
329 goto cleanup;
330 }
331 clone = posix_acl_clone(acl, GFP_KERNEL); 344 clone = posix_acl_clone(acl, GFP_KERNEL);
332 rc = -ENOMEM;
333 if (!clone) 345 if (!clone)
334 goto cleanup; 346 return -ENOMEM;
335 mode = inode->i_mode; 347 rc = posix_acl_create_masq(clone, (mode_t *)i_mode);
336 rc = posix_acl_create_masq(clone, &mode); 348 if (rc < 0)
337 if (rc >= 0) { 349 return rc;
338 inode->i_mode = mode; 350 if (rc > 0)
339 if (rc > 0) 351 jffs2_iset_acl(inode, &f->i_acl_access, clone);
340 rc = jffs2_set_acl(inode, ACL_TYPE_ACCESS, clone); 352
341 }
342 posix_acl_release(clone); 353 posix_acl_release(clone);
343 } 354 }
344 cleanup: 355 return 0;
345 posix_acl_release(acl); 356}
357
358int jffs2_init_acl_post(struct inode *inode)
359{
360 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
361 int rc;
362
363 if (f->i_acl_default) {
364 rc = __jffs2_set_acl(inode, JFFS2_XPREFIX_ACL_DEFAULT, f->i_acl_default);
365 if (rc)
366 return rc;
367 }
368
369 if (f->i_acl_access) {
370 rc = __jffs2_set_acl(inode, JFFS2_XPREFIX_ACL_ACCESS, f->i_acl_access);
371 if (rc)
372 return rc;
373 }
374
346 return rc; 375 return rc;
347} 376}
348 377
diff --git a/fs/jffs2/acl.h b/fs/jffs2/acl.h
index 90a2dbf59051..76c6ebd1acd9 100644
--- a/fs/jffs2/acl.h
+++ b/fs/jffs2/acl.h
@@ -31,7 +31,8 @@ struct jffs2_acl_header {
31extern struct posix_acl *jffs2_get_acl(struct inode *inode, int type); 31extern struct posix_acl *jffs2_get_acl(struct inode *inode, int type);
32extern int jffs2_permission(struct inode *, int, struct nameidata *); 32extern int jffs2_permission(struct inode *, int, struct nameidata *);
33extern int jffs2_acl_chmod(struct inode *); 33extern int jffs2_acl_chmod(struct inode *);
34extern int jffs2_init_acl(struct inode *, struct posix_acl *); 34extern int jffs2_init_acl_pre(struct inode *, struct inode *, int *);
35extern int jffs2_init_acl_post(struct inode *);
35extern void jffs2_clear_acl(struct jffs2_inode_info *); 36extern void jffs2_clear_acl(struct jffs2_inode_info *);
36 37
37extern struct xattr_handler jffs2_acl_access_xattr_handler; 38extern struct xattr_handler jffs2_acl_access_xattr_handler;
@@ -39,10 +40,11 @@ extern struct xattr_handler jffs2_acl_default_xattr_handler;
39 40
40#else 41#else
41 42
42#define jffs2_get_acl(inode, type) (NULL) 43#define jffs2_get_acl(inode, type) (NULL)
43#define jffs2_permission NULL 44#define jffs2_permission (NULL)
44#define jffs2_acl_chmod(inode) (0) 45#define jffs2_acl_chmod(inode) (0)
45#define jffs2_init_acl(inode,dir) (0) 46#define jffs2_init_acl_pre(dir_i,inode,mode) (0)
47#define jffs2_init_acl_post(inode) (0)
46#define jffs2_clear_acl(f) 48#define jffs2_clear_acl(f)
47 49
48#endif /* CONFIG_JFFS2_FS_POSIX_ACL */ 50#endif /* CONFIG_JFFS2_FS_POSIX_ACL */
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index 8353eb9c1799..787e392ffd41 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -182,7 +182,6 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry, int mode,
182 struct jffs2_inode_info *f, *dir_f; 182 struct jffs2_inode_info *f, *dir_f;
183 struct jffs2_sb_info *c; 183 struct jffs2_sb_info *c;
184 struct inode *inode; 184 struct inode *inode;
185 struct posix_acl *acl;
186 int ret; 185 int ret;
187 186
188 ri = jffs2_alloc_raw_inode(); 187 ri = jffs2_alloc_raw_inode();
@@ -193,7 +192,7 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry, int mode,
193 192
194 D1(printk(KERN_DEBUG "jffs2_create()\n")); 193 D1(printk(KERN_DEBUG "jffs2_create()\n"));
195 194
196 inode = jffs2_new_inode(dir_i, mode, ri, &acl); 195 inode = jffs2_new_inode(dir_i, mode, ri);
197 196
198 if (IS_ERR(inode)) { 197 if (IS_ERR(inode)) {
199 D1(printk(KERN_DEBUG "jffs2_new_inode() failed\n")); 198 D1(printk(KERN_DEBUG "jffs2_new_inode() failed\n"));
@@ -211,14 +210,6 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry, int mode,
211 210
212 ret = jffs2_do_create(c, dir_f, f, ri, 211 ret = jffs2_do_create(c, dir_f, f, ri,
213 dentry->d_name.name, dentry->d_name.len); 212 dentry->d_name.name, dentry->d_name.len);
214
215 if (ret)
216 goto fail_acl;
217
218 ret = jffs2_init_security(inode, dir_i);
219 if (ret)
220 goto fail_acl;
221 ret = jffs2_init_acl(inode, acl);
222 if (ret) 213 if (ret)
223 goto fail; 214 goto fail;
224 215
@@ -231,8 +222,6 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry, int mode,
231 inode->i_ino, inode->i_mode, inode->i_nlink, f->inocache->nlink, inode->i_mapping->nrpages)); 222 inode->i_ino, inode->i_mode, inode->i_nlink, f->inocache->nlink, inode->i_mapping->nrpages));
232 return 0; 223 return 0;
233 224
234 fail_acl:
235 posix_acl_release(acl);
236 fail: 225 fail:
237 make_bad_inode(inode); 226 make_bad_inode(inode);
238 iput(inode); 227 iput(inode);
@@ -309,7 +298,6 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
309 struct jffs2_full_dirent *fd; 298 struct jffs2_full_dirent *fd;
310 int namelen; 299 int namelen;
311 uint32_t alloclen; 300 uint32_t alloclen;
312 struct posix_acl *acl;
313 int ret, targetlen = strlen(target); 301 int ret, targetlen = strlen(target);
314 302
315 /* FIXME: If you care. We'd need to use frags for the target 303 /* FIXME: If you care. We'd need to use frags for the target
@@ -336,7 +324,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
336 return ret; 324 return ret;
337 } 325 }
338 326
339 inode = jffs2_new_inode(dir_i, S_IFLNK | S_IRWXUGO, ri, &acl); 327 inode = jffs2_new_inode(dir_i, S_IFLNK | S_IRWXUGO, ri);
340 328
341 if (IS_ERR(inode)) { 329 if (IS_ERR(inode)) {
342 jffs2_free_raw_inode(ri); 330 jffs2_free_raw_inode(ri);
@@ -366,7 +354,6 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
366 up(&f->sem); 354 up(&f->sem);
367 jffs2_complete_reservation(c); 355 jffs2_complete_reservation(c);
368 jffs2_clear_inode(inode); 356 jffs2_clear_inode(inode);
369 posix_acl_release(acl);
370 return PTR_ERR(fn); 357 return PTR_ERR(fn);
371 } 358 }
372 359
@@ -377,7 +364,6 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
377 up(&f->sem); 364 up(&f->sem);
378 jffs2_complete_reservation(c); 365 jffs2_complete_reservation(c);
379 jffs2_clear_inode(inode); 366 jffs2_clear_inode(inode);
380 posix_acl_release(acl);
381 return -ENOMEM; 367 return -ENOMEM;
382 } 368 }
383 369
@@ -395,10 +381,9 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
395 ret = jffs2_init_security(inode, dir_i); 381 ret = jffs2_init_security(inode, dir_i);
396 if (ret) { 382 if (ret) {
397 jffs2_clear_inode(inode); 383 jffs2_clear_inode(inode);
398 posix_acl_release(acl);
399 return ret; 384 return ret;
400 } 385 }
401 ret = jffs2_init_acl(inode, acl); 386 ret = jffs2_init_acl_post(inode);
402 if (ret) { 387 if (ret) {
403 jffs2_clear_inode(inode); 388 jffs2_clear_inode(inode);
404 return ret; 389 return ret;
@@ -476,7 +461,6 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
476 struct jffs2_full_dirent *fd; 461 struct jffs2_full_dirent *fd;
477 int namelen; 462 int namelen;
478 uint32_t alloclen; 463 uint32_t alloclen;
479 struct posix_acl *acl;
480 int ret; 464 int ret;
481 465
482 mode |= S_IFDIR; 466 mode |= S_IFDIR;
@@ -499,7 +483,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
499 return ret; 483 return ret;
500 } 484 }
501 485
502 inode = jffs2_new_inode(dir_i, mode, ri, &acl); 486 inode = jffs2_new_inode(dir_i, mode, ri);
503 487
504 if (IS_ERR(inode)) { 488 if (IS_ERR(inode)) {
505 jffs2_free_raw_inode(ri); 489 jffs2_free_raw_inode(ri);
@@ -526,7 +510,6 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
526 up(&f->sem); 510 up(&f->sem);
527 jffs2_complete_reservation(c); 511 jffs2_complete_reservation(c);
528 jffs2_clear_inode(inode); 512 jffs2_clear_inode(inode);
529 posix_acl_release(acl);
530 return PTR_ERR(fn); 513 return PTR_ERR(fn);
531 } 514 }
532 /* No data here. Only a metadata node, which will be 515 /* No data here. Only a metadata node, which will be
@@ -540,10 +523,9 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
540 ret = jffs2_init_security(inode, dir_i); 523 ret = jffs2_init_security(inode, dir_i);
541 if (ret) { 524 if (ret) {
542 jffs2_clear_inode(inode); 525 jffs2_clear_inode(inode);
543 posix_acl_release(acl);
544 return ret; 526 return ret;
545 } 527 }
546 ret = jffs2_init_acl(inode, acl); 528 ret = jffs2_init_acl_post(inode);
547 if (ret) { 529 if (ret) {
548 jffs2_clear_inode(inode); 530 jffs2_clear_inode(inode);
549 return ret; 531 return ret;
@@ -639,7 +621,6 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
639 union jffs2_device_node dev; 621 union jffs2_device_node dev;
640 int devlen = 0; 622 int devlen = 0;
641 uint32_t alloclen; 623 uint32_t alloclen;
642 struct posix_acl *acl;
643 int ret; 624 int ret;
644 625
645 if (!new_valid_dev(rdev)) 626 if (!new_valid_dev(rdev))
@@ -666,7 +647,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
666 return ret; 647 return ret;
667 } 648 }
668 649
669 inode = jffs2_new_inode(dir_i, mode, ri, &acl); 650 inode = jffs2_new_inode(dir_i, mode, ri);
670 651
671 if (IS_ERR(inode)) { 652 if (IS_ERR(inode)) {
672 jffs2_free_raw_inode(ri); 653 jffs2_free_raw_inode(ri);
@@ -695,7 +676,6 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
695 up(&f->sem); 676 up(&f->sem);
696 jffs2_complete_reservation(c); 677 jffs2_complete_reservation(c);
697 jffs2_clear_inode(inode); 678 jffs2_clear_inode(inode);
698 posix_acl_release(acl);
699 return PTR_ERR(fn); 679 return PTR_ERR(fn);
700 } 680 }
701 /* No data here. Only a metadata node, which will be 681 /* No data here. Only a metadata node, which will be
@@ -709,10 +689,9 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de
709 ret = jffs2_init_security(inode, dir_i); 689 ret = jffs2_init_security(inode, dir_i);
710 if (ret) { 690 if (ret) {
711 jffs2_clear_inode(inode); 691 jffs2_clear_inode(inode);
712 posix_acl_release(acl);
713 return ret; 692 return ret;
714 } 693 }
715 ret = jffs2_init_acl(inode, acl); 694 ret = jffs2_init_acl_post(inode);
716 if (ret) { 695 if (ret) {
717 jffs2_clear_inode(inode); 696 jffs2_clear_inode(inode);
718 return ret; 697 return ret;
diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c
index 023a17539dd4..f9c5dd6f4b64 100644
--- a/fs/jffs2/file.c
+++ b/fs/jffs2/file.c
@@ -255,7 +255,7 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping,
255 _whole_ page. This helps to reduce the number of 255 _whole_ page. This helps to reduce the number of
256 nodes in files which have many short writes, like 256 nodes in files which have many short writes, like
257 syslog files. */ 257 syslog files. */
258 start = aligned_start = 0; 258 aligned_start = 0;
259 } 259 }
260 260
261 ri = jffs2_alloc_raw_inode(); 261 ri = jffs2_alloc_raw_inode();
@@ -291,14 +291,11 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping,
291 } 291 }
292 292
293 /* Adjust writtenlen for the padding we did, so we don't confuse our caller */ 293 /* Adjust writtenlen for the padding we did, so we don't confuse our caller */
294 if (writtenlen < (start&3)) 294 writtenlen -= min(writtenlen, (start - aligned_start));
295 writtenlen = 0;
296 else
297 writtenlen -= (start&3);
298 295
299 if (writtenlen) { 296 if (writtenlen) {
300 if (inode->i_size < (pg->index << PAGE_CACHE_SHIFT) + start + writtenlen) { 297 if (inode->i_size < pos + writtenlen) {
301 inode->i_size = (pg->index << PAGE_CACHE_SHIFT) + start + writtenlen; 298 inode->i_size = pos + writtenlen;
302 inode->i_blocks = (inode->i_size + 511) >> 9; 299 inode->i_blocks = (inode->i_size + 511) >> 9;
303 300
304 inode->i_ctime = inode->i_mtime = ITIME(je32_to_cpu(ri->ctime)); 301 inode->i_ctime = inode->i_mtime = ITIME(je32_to_cpu(ri->ctime));
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index ed85f9afdbc8..d2e06f7ea96f 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -402,8 +402,7 @@ void jffs2_write_super (struct super_block *sb)
402 402
403/* jffs2_new_inode: allocate a new inode and inocache, add it to the hash, 403/* jffs2_new_inode: allocate a new inode and inocache, add it to the hash,
404 fill in the raw_inode while you're at it. */ 404 fill in the raw_inode while you're at it. */
405struct inode *jffs2_new_inode (struct inode *dir_i, int mode, struct jffs2_raw_inode *ri, 405struct inode *jffs2_new_inode (struct inode *dir_i, int mode, struct jffs2_raw_inode *ri)
406 struct posix_acl **acl)
407{ 406{
408 struct inode *inode; 407 struct inode *inode;
409 struct super_block *sb = dir_i->i_sb; 408 struct super_block *sb = dir_i->i_sb;
@@ -438,19 +437,11 @@ struct inode *jffs2_new_inode (struct inode *dir_i, int mode, struct jffs2_raw_i
438 437
439 /* POSIX ACLs have to be processed now, at least partly. 438 /* POSIX ACLs have to be processed now, at least partly.
440 The umask is only applied if there's no default ACL */ 439 The umask is only applied if there's no default ACL */
441 if (!S_ISLNK(mode)) { 440 ret = jffs2_init_acl_pre(dir_i, inode, &mode);
442 *acl = jffs2_get_acl(dir_i, ACL_TYPE_DEFAULT); 441 if (ret) {
443 if (IS_ERR(*acl)) { 442 make_bad_inode(inode);
444 make_bad_inode(inode); 443 iput(inode);
445 iput(inode); 444 return ERR_PTR(ret);
446 inode = (void *)*acl;
447 *acl = NULL;
448 return inode;
449 }
450 if (!(*acl))
451 mode &= ~current->fs->umask;
452 } else {
453 *acl = NULL;
454 } 445 }
455 ret = jffs2_do_new_inode (c, f, mode, ri); 446 ret = jffs2_do_new_inode (c, f, mode, ri);
456 if (ret) { 447 if (ret) {
diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h
index f6743a915cf3..bf64686cf098 100644
--- a/fs/jffs2/os-linux.h
+++ b/fs/jffs2/os-linux.h
@@ -173,15 +173,13 @@ int jffs2_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
173extern const struct inode_operations jffs2_symlink_inode_operations; 173extern const struct inode_operations jffs2_symlink_inode_operations;
174 174
175/* fs.c */ 175/* fs.c */
176struct posix_acl;
177
178int jffs2_setattr (struct dentry *, struct iattr *); 176int jffs2_setattr (struct dentry *, struct iattr *);
179int jffs2_do_setattr (struct inode *, struct iattr *); 177int jffs2_do_setattr (struct inode *, struct iattr *);
180void jffs2_read_inode (struct inode *); 178void jffs2_read_inode (struct inode *);
181void jffs2_clear_inode (struct inode *); 179void jffs2_clear_inode (struct inode *);
182void jffs2_dirty_inode(struct inode *inode); 180void jffs2_dirty_inode(struct inode *inode);
183struct inode *jffs2_new_inode (struct inode *dir_i, int mode, 181struct inode *jffs2_new_inode (struct inode *dir_i, int mode,
184 struct jffs2_raw_inode *ri, struct posix_acl **acl); 182 struct jffs2_raw_inode *ri);
185int jffs2_statfs (struct dentry *, struct kstatfs *); 183int jffs2_statfs (struct dentry *, struct kstatfs *);
186void jffs2_write_super (struct super_block *); 184void jffs2_write_super (struct super_block *);
187int jffs2_remount_fs (struct super_block *, int *, char *); 185int jffs2_remount_fs (struct super_block *, int *, char *);
diff --git a/fs/jffs2/write.c b/fs/jffs2/write.c
index 2f5695446d0f..147e2cbee9e4 100644
--- a/fs/jffs2/write.c
+++ b/fs/jffs2/write.c
@@ -465,6 +465,14 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, str
465 465
466 up(&f->sem); 466 up(&f->sem);
467 jffs2_complete_reservation(c); 467 jffs2_complete_reservation(c);
468
469 ret = jffs2_init_security(&f->vfs_inode, &dir_f->vfs_inode);
470 if (ret)
471 return ret;
472 ret = jffs2_init_acl_post(&f->vfs_inode);
473 if (ret)
474 return ret;
475
468 ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &alloclen, 476 ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &alloclen,
469 ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); 477 ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen));
470 478
diff --git a/lib/reed_solomon/decode_rs.c b/lib/reed_solomon/decode_rs.c
index a58df56f09b6..0ec3f257ffdf 100644
--- a/lib/reed_solomon/decode_rs.c
+++ b/lib/reed_solomon/decode_rs.c
@@ -39,8 +39,7 @@
39 39
40 /* Check length parameter for validity */ 40 /* Check length parameter for validity */
41 pad = nn - nroots - len; 41 pad = nn - nroots - len;
42 if (pad < 0 || pad >= nn) 42 BUG_ON(pad < 0 || pad >= nn);
43 return -ERANGE;
44 43
45 /* Does the caller provide the syndrome ? */ 44 /* Does the caller provide the syndrome ? */
46 if (s != NULL) 45 if (s != NULL)
@@ -203,7 +202,7 @@
203 * deg(lambda) unequal to number of roots => uncorrectable 202 * deg(lambda) unequal to number of roots => uncorrectable
204 * error detected 203 * error detected
205 */ 204 */
206 count = -1; 205 count = -EBADMSG;
207 goto finish; 206 goto finish;
208 } 207 }
209 /* 208 /*
diff --git a/lib/reed_solomon/reed_solomon.c b/lib/reed_solomon/reed_solomon.c
index 5b0d8522b7ca..3ea2db94d5b0 100644
--- a/lib/reed_solomon/reed_solomon.c
+++ b/lib/reed_solomon/reed_solomon.c
@@ -320,6 +320,7 @@ EXPORT_SYMBOL_GPL(encode_rs8);
320 * The syndrome and parity uses a uint16_t data type to enable 320 * The syndrome and parity uses a uint16_t data type to enable
321 * symbol size > 8. The calling code must take care of decoding of the 321 * symbol size > 8. The calling code must take care of decoding of the
322 * syndrome result and the received parity before calling this code. 322 * syndrome result and the received parity before calling this code.
323 * Returns the number of corrected bits or -EBADMSG for uncorrectable errors.
323 */ 324 */
324int decode_rs8(struct rs_control *rs, uint8_t *data, uint16_t *par, int len, 325int decode_rs8(struct rs_control *rs, uint8_t *data, uint16_t *par, int len,
325 uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk, 326 uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk,
@@ -363,6 +364,7 @@ EXPORT_SYMBOL_GPL(encode_rs16);
363 * @corr: buffer to store correction bitmask on eras_pos 364 * @corr: buffer to store correction bitmask on eras_pos
364 * 365 *
365 * Each field in the data array contains up to symbol size bits of valid data. 366 * Each field in the data array contains up to symbol size bits of valid data.
367 * Returns the number of corrected bits or -EBADMSG for uncorrectable errors.
366 */ 368 */
367int decode_rs16(struct rs_control *rs, uint16_t *data, uint16_t *par, int len, 369int decode_rs16(struct rs_control *rs, uint16_t *data, uint16_t *par, int len,
368 uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk, 370 uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk,