Esempio n. 1
0
static int nftl_writeblock(struct mtd_blktrans_dev *mbd, unsigned long block,
                           char *buffer)
{
    struct NFTLrecord *nftl = (void *)mbd;
    u16 writeEUN;
    unsigned long blockofs = (block * 512) & (nftl->EraseSize - 1);
    size_t retlen;
    struct nftl_oob oob;

    writeEUN = NFTL_findwriteunit(nftl, block);

    if (writeEUN == BLOCK_NIL) {
        printk(KERN_WARNING
               "NFTL_writeblock(): Cannot find block to write to\n");
        /* If we _still_ haven't got a block to use, we're screwed */
        return 1;
    }

    memset(&oob, 0xff, sizeof(struct nftl_oob));
    oob.b.Status = oob.b.Status1 = SECTOR_USED;
    MTD_WRITEECC(nftl->mbd.mtd, (writeEUN * nftl->EraseSize) + blockofs,
                 512, &retlen, (char *)buffer, (char *)&oob, &nftl->oobinfo);
    /* need to write SECTOR_USED flags since they are not written in mtd_writeecc */

    return 0;
}
Esempio n. 2
0
static int NFTL_writeblock(struct NFTLrecord *nftl, unsigned block, char *buffer)
{
	u16 writeEUN;
	unsigned long blockofs = (block * 512) & (nftl->EraseSize - 1);
	size_t retlen;
	u8 eccbuf[6];

	writeEUN = NFTL_findwriteunit(nftl, block);

	if (writeEUN == BLOCK_NIL) {
		printk(KERN_WARNING
		       "NFTL_writeblock(): Cannot find block to write to\n");
		/* If we _still_ haven't got a block to use, we're screwed */
		return 1;
	}

	MTD_WRITEECC(nftl->mtd, (writeEUN * nftl->EraseSize) + blockofs,
		     512, &retlen, (char *)buffer, (char *)eccbuf, NAND_ECC_DISKONCHIP);
        /* no need to write SECTOR_USED flags since they are written in mtd_writeecc */

	return 0;
}