rtl8192c:dm: Properly initialize local array and set value.
[pandora-kernel.git] / drivers / mtd / nftlcore.c
index b155666..cda77b5 100644 (file)
@@ -63,14 +63,12 @@ static void nftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
                return;
        }
 
-       DEBUG(MTD_DEBUG_LEVEL1, "NFTL: add_mtd for %s\n", mtd->name);
+       pr_debug("NFTL: add_mtd for %s\n", mtd->name);
 
        nftl = kzalloc(sizeof(struct NFTLrecord), GFP_KERNEL);
 
-       if (!nftl) {
-               printk(KERN_WARNING "NFTL: out of memory for data structures\n");
+       if (!nftl)
                return;
-       }
 
        nftl->mbd.mtd = mtd;
        nftl->mbd.devnum = -1;
@@ -132,7 +130,7 @@ static void nftl_remove_dev(struct mtd_blktrans_dev *dev)
 {
        struct NFTLrecord *nftl = (void *)dev;
 
-       DEBUG(MTD_DEBUG_LEVEL1, "NFTL: remove_dev (i=%d)\n", dev->devnum);
+       pr_debug("NFTL: remove_dev (i=%d)\n", dev->devnum);
 
        del_mtd_blktrans_dev(dev);
        kfree(nftl->ReplUnitTable);
@@ -149,7 +147,7 @@ int nftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len,
        struct mtd_oob_ops ops;
        int res;
 
-       ops.mode = MTD_OOB_PLACE;
+       ops.mode = MTD_OPS_PLACE_OOB;
        ops.ooboffs = offs & mask;
        ops.ooblen = len;
        ops.oobbuf = buf;
@@ -170,7 +168,7 @@ int nftl_write_oob(struct mtd_info *mtd, loff_t offs, size_t len,
        struct mtd_oob_ops ops;
        int res;
 
-       ops.mode = MTD_OOB_PLACE;
+       ops.mode = MTD_OPS_PLACE_OOB;
        ops.ooboffs = offs & mask;
        ops.ooblen = len;
        ops.oobbuf = buf;
@@ -193,7 +191,7 @@ static int nftl_write(struct mtd_info *mtd, loff_t offs, size_t len,
        struct mtd_oob_ops ops;
        int res;
 
-       ops.mode = MTD_OOB_PLACE;
+       ops.mode = MTD_OPS_PLACE_OOB;
        ops.ooboffs = offs & mask;
        ops.ooblen = mtd->oobsize;
        ops.oobbuf = oob;
@@ -220,7 +218,7 @@ static u16 NFTL_findfreeblock(struct NFTLrecord *nftl, int desperate )
 
        /* Normally, we force a fold to happen before we run out of free blocks completely */
        if (!desperate && nftl->numfreeEUNs < 2) {
-               DEBUG(MTD_DEBUG_LEVEL1, "NFTL_findfreeblock: there are too few free EUNs\n");
+               pr_debug("NFTL_findfreeblock: there are too few free EUNs\n");
                return BLOCK_NIL;
        }
 
@@ -291,8 +289,7 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
                        if (block == 2) {
                                foldmark = oob.u.c.FoldMark | oob.u.c.FoldMark1;
                                if (foldmark == FOLD_MARK_IN_PROGRESS) {
-                                       DEBUG(MTD_DEBUG_LEVEL1,
-                                             "Write Inhibited on EUN %d\n", thisEUN);
+                                       pr_debug("Write Inhibited on EUN %d\n", thisEUN);
                                        inplace = 0;
                                } else {
                                        /* There's no other reason not to do inplace,
@@ -357,7 +354,7 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
                        if (BlockLastState[block] != SECTOR_FREE &&
                            BlockMap[block] != BLOCK_NIL &&
                            BlockMap[block] != targetEUN) {
-                               DEBUG(MTD_DEBUG_LEVEL1, "Setting inplace to 0. VUC %d, "
+                               pr_debug("Setting inplace to 0. VUC %d, "
                                      "block %d was %x lastEUN, "
                                      "and is in EUN %d (%s) %d\n",
                                      thisVUC, block, BlockLastState[block],
@@ -373,14 +370,14 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
                    pendingblock < ((thisVUC + 1)* (nftl->EraseSize / 512)) &&
                    BlockLastState[pendingblock - (thisVUC * (nftl->EraseSize / 512))] !=
                    SECTOR_FREE) {
-                       DEBUG(MTD_DEBUG_LEVEL1, "Pending write not free in EUN %d. "
+                       pr_debug("Pending write not free in EUN %d. "
                              "Folding out of place.\n", targetEUN);
                        inplace = 0;
                }
        }
 
        if (!inplace) {
-               DEBUG(MTD_DEBUG_LEVEL1, "Cannot fold Virtual Unit Chain %d in place. "
+               pr_debug("Cannot fold Virtual Unit Chain %d in place. "
                      "Trying out-of-place\n", thisVUC);
                /* We need to find a targetEUN to fold into. */
                targetEUN = NFTL_findfreeblock(nftl, 1);
@@ -410,7 +407,7 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
           and the Erase Unit into which we are supposed to be copying.
           Go for it.
        */
-       DEBUG(MTD_DEBUG_LEVEL1,"Folding chain %d into unit %d\n", thisVUC, targetEUN);
+       pr_debug("Folding chain %d into unit %d\n", thisVUC, targetEUN);
        for (block = 0; block < nftl->EraseSize / 512 ; block++) {
                unsigned char movebuf[512];
                int ret;
@@ -428,7 +425,7 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
 
                ret = mtd->read(mtd, (nftl->EraseSize * BlockMap[block]) + (block * 512),
                                512, &retlen, movebuf);
-               if (ret < 0 && ret != -EUCLEAN) {
+               if (ret < 0 && !mtd_is_bitflip(ret)) {
                        ret = mtd->read(mtd, (nftl->EraseSize * BlockMap[block])
                                        + (block * 512), 512, &retlen,
                                        movebuf);
@@ -457,7 +454,7 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
           has duplicate chains, we need to free one of the chains because it's not necessary any more.
        */
        thisEUN = nftl->EUNtable[thisVUC];
-       DEBUG(MTD_DEBUG_LEVEL1,"Want to erase\n");
+       pr_debug("Want to erase\n");
 
        /* For each block in the old chain (except the targetEUN of course),
           free it and make it available for future use */
@@ -570,7 +567,7 @@ static inline u16 NFTL_findwriteunit(struct NFTLrecord *nftl, unsigned block)
                                      (writeEUN * nftl->EraseSize) + blockofs,
                                      8, &retlen, (char *)&bci);
 
-                       DEBUG(MTD_DEBUG_LEVEL2, "Status of block %d in EUN %d is %x\n",
+                       pr_debug("Status of block %d in EUN %d is %x\n",
                              block , writeEUN, le16_to_cpu(bci.Status));
 
                        status = bci.Status | bci.Status1;
@@ -623,7 +620,7 @@ static inline u16 NFTL_findwriteunit(struct NFTLrecord *nftl, unsigned block)
                                   but they are reserved for when we're
                                   desperate. Well, now we're desperate.
                                */
-                               DEBUG(MTD_DEBUG_LEVEL1, "Using desperate==1 to find free EUN to accommodate write to VUC %d\n", thisVUC);
+                               pr_debug("Using desperate==1 to find free EUN to accommodate write to VUC %d\n", thisVUC);
                                writeEUN = NFTL_findfreeblock(nftl, 1);
                        }
                        if (writeEUN == BLOCK_NIL) {
@@ -776,7 +773,7 @@ static int nftl_readblock(struct mtd_blktrans_dev *mbd, unsigned long block,
                size_t retlen;
                int res = mtd->read(mtd, ptr, 512, &retlen, buffer);
 
-               if (res < 0 && res != -EUCLEAN)
+               if (res < 0 && !mtd_is_bitflip(res))
                        return -EIO;
        }
        return 0;