Root/target/linux/generic/files/fs/yaffs2/yaffs_mtdif.c

1/*
2 * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
3 *
4 * Copyright (C) 2002-2010 Aleph One Ltd.
5 * for Toby Churchill Ltd and Brightstar Engineering
6 *
7 * Created by Charles Manning <charles@aleph1.co.uk>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#include "yportenv.h"
15
16
17#include "yaffs_mtdif.h"
18
19#include "linux/mtd/mtd.h"
20#include "linux/types.h"
21#include "linux/time.h"
22#include "linux/mtd/nand.h"
23
24#include "yaffs_linux.h"
25
26int nandmtd_EraseBlockInNAND(yaffs_dev_t *dev, int blockNumber)
27{
28    struct mtd_info *mtd = yaffs_dev_to_mtd(dev);
29    __u32 addr =
30        ((loff_t) blockNumber) * dev->param.total_bytes_per_chunk
31        * dev->param.chunks_per_block;
32    struct erase_info ei;
33    
34    int retval = 0;
35
36    ei.mtd = mtd;
37    ei.addr = addr;
38    ei.len = dev->param.total_bytes_per_chunk * dev->param.chunks_per_block;
39    ei.time = 1000;
40    ei.retries = 2;
41    ei.callback = NULL;
42    ei.priv = (u_long) dev;
43
44    retval = mtd->erase(mtd, &ei);
45
46    if (retval == 0)
47        return YAFFS_OK;
48    else
49        return YAFFS_FAIL;
50}
51
52int nandmtd_InitialiseNAND(yaffs_dev_t *dev)
53{
54    return YAFFS_OK;
55}
56
57

Archive Download this file



interactive