Linux 2.6.17.7
[linux/fpc-iii.git] / fs / jffs2 / fs.c
blob09e5d10b88401ca736bbd70d099d847fd9698bed
1 /*
2 * JFFS2 -- Journalling Flash File System, Version 2.
4 * Copyright (C) 2001-2003 Red Hat, Inc.
6 * Created by David Woodhouse <dwmw2@infradead.org>
8 * For licensing information, see the file 'LICENCE' in this directory.
10 * $Id: fs.c,v 1.66 2005/09/27 13:17:29 dedekind Exp $
14 #include <linux/capability.h>
15 #include <linux/config.h>
16 #include <linux/kernel.h>
17 #include <linux/sched.h>
18 #include <linux/fs.h>
19 #include <linux/list.h>
20 #include <linux/mtd/mtd.h>
21 #include <linux/pagemap.h>
22 #include <linux/slab.h>
23 #include <linux/vmalloc.h>
24 #include <linux/vfs.h>
25 #include <linux/crc32.h>
26 #include "nodelist.h"
28 static int jffs2_flash_setup(struct jffs2_sb_info *c);
30 static int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
32 struct jffs2_full_dnode *old_metadata, *new_metadata;
33 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
34 struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
35 struct jffs2_raw_inode *ri;
36 unsigned short dev;
37 unsigned char *mdata = NULL;
38 int mdatalen = 0;
39 unsigned int ivalid;
40 uint32_t phys_ofs, alloclen;
41 int ret;
42 D1(printk(KERN_DEBUG "jffs2_setattr(): ino #%lu\n", inode->i_ino));
43 ret = inode_change_ok(inode, iattr);
44 if (ret)
45 return ret;
47 /* Special cases - we don't want more than one data node
48 for these types on the medium at any time. So setattr
49 must read the original data associated with the node
50 (i.e. the device numbers or the target name) and write
51 it out again with the appropriate data attached */
52 if (S_ISBLK(inode->i_mode) || S_ISCHR(inode->i_mode)) {
53 /* For these, we don't actually need to read the old node */
54 dev = old_encode_dev(inode->i_rdev);
55 mdata = (char *)&dev;
56 mdatalen = sizeof(dev);
57 D1(printk(KERN_DEBUG "jffs2_setattr(): Writing %d bytes of kdev_t\n", mdatalen));
58 } else if (S_ISLNK(inode->i_mode)) {
59 mdatalen = f->metadata->size;
60 mdata = kmalloc(f->metadata->size, GFP_USER);
61 if (!mdata)
62 return -ENOMEM;
63 ret = jffs2_read_dnode(c, f, f->metadata, mdata, 0, mdatalen);
64 if (ret) {
65 kfree(mdata);
66 return ret;
68 D1(printk(KERN_DEBUG "jffs2_setattr(): Writing %d bytes of symlink target\n", mdatalen));
71 ri = jffs2_alloc_raw_inode();
72 if (!ri) {
73 if (S_ISLNK(inode->i_mode))
74 kfree(mdata);
75 return -ENOMEM;
78 ret = jffs2_reserve_space(c, sizeof(*ri) + mdatalen, &phys_ofs, &alloclen,
79 ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
80 if (ret) {
81 jffs2_free_raw_inode(ri);
82 if (S_ISLNK(inode->i_mode & S_IFMT))
83 kfree(mdata);
84 return ret;
86 down(&f->sem);
87 ivalid = iattr->ia_valid;
89 ri->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
90 ri->nodetype = cpu_to_je16(JFFS2_NODETYPE_INODE);
91 ri->totlen = cpu_to_je32(sizeof(*ri) + mdatalen);
92 ri->hdr_crc = cpu_to_je32(crc32(0, ri, sizeof(struct jffs2_unknown_node)-4));
94 ri->ino = cpu_to_je32(inode->i_ino);
95 ri->version = cpu_to_je32(++f->highest_version);
97 ri->uid = cpu_to_je16((ivalid & ATTR_UID)?iattr->ia_uid:inode->i_uid);
98 ri->gid = cpu_to_je16((ivalid & ATTR_GID)?iattr->ia_gid:inode->i_gid);
100 if (ivalid & ATTR_MODE)
101 if (iattr->ia_mode & S_ISGID &&
102 !in_group_p(je16_to_cpu(ri->gid)) && !capable(CAP_FSETID))
103 ri->mode = cpu_to_jemode(iattr->ia_mode & ~S_ISGID);
104 else
105 ri->mode = cpu_to_jemode(iattr->ia_mode);
106 else
107 ri->mode = cpu_to_jemode(inode->i_mode);
110 ri->isize = cpu_to_je32((ivalid & ATTR_SIZE)?iattr->ia_size:inode->i_size);
111 ri->atime = cpu_to_je32(I_SEC((ivalid & ATTR_ATIME)?iattr->ia_atime:inode->i_atime));
112 ri->mtime = cpu_to_je32(I_SEC((ivalid & ATTR_MTIME)?iattr->ia_mtime:inode->i_mtime));
113 ri->ctime = cpu_to_je32(I_SEC((ivalid & ATTR_CTIME)?iattr->ia_ctime:inode->i_ctime));
115 ri->offset = cpu_to_je32(0);
116 ri->csize = ri->dsize = cpu_to_je32(mdatalen);
117 ri->compr = JFFS2_COMPR_NONE;
118 if (ivalid & ATTR_SIZE && inode->i_size < iattr->ia_size) {
119 /* It's an extension. Make it a hole node */
120 ri->compr = JFFS2_COMPR_ZERO;
121 ri->dsize = cpu_to_je32(iattr->ia_size - inode->i_size);
122 ri->offset = cpu_to_je32(inode->i_size);
124 ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
125 if (mdatalen)
126 ri->data_crc = cpu_to_je32(crc32(0, mdata, mdatalen));
127 else
128 ri->data_crc = cpu_to_je32(0);
130 new_metadata = jffs2_write_dnode(c, f, ri, mdata, mdatalen, phys_ofs, ALLOC_NORMAL);
131 if (S_ISLNK(inode->i_mode))
132 kfree(mdata);
134 if (IS_ERR(new_metadata)) {
135 jffs2_complete_reservation(c);
136 jffs2_free_raw_inode(ri);
137 up(&f->sem);
138 return PTR_ERR(new_metadata);
140 /* It worked. Update the inode */
141 inode->i_atime = ITIME(je32_to_cpu(ri->atime));
142 inode->i_ctime = ITIME(je32_to_cpu(ri->ctime));
143 inode->i_mtime = ITIME(je32_to_cpu(ri->mtime));
144 inode->i_mode = jemode_to_cpu(ri->mode);
145 inode->i_uid = je16_to_cpu(ri->uid);
146 inode->i_gid = je16_to_cpu(ri->gid);
149 old_metadata = f->metadata;
151 if (ivalid & ATTR_SIZE && inode->i_size > iattr->ia_size)
152 jffs2_truncate_fragtree (c, &f->fragtree, iattr->ia_size);
154 if (ivalid & ATTR_SIZE && inode->i_size < iattr->ia_size) {
155 jffs2_add_full_dnode_to_inode(c, f, new_metadata);
156 inode->i_size = iattr->ia_size;
157 f->metadata = NULL;
158 } else {
159 f->metadata = new_metadata;
161 if (old_metadata) {
162 jffs2_mark_node_obsolete(c, old_metadata->raw);
163 jffs2_free_full_dnode(old_metadata);
165 jffs2_free_raw_inode(ri);
167 up(&f->sem);
168 jffs2_complete_reservation(c);
170 /* We have to do the vmtruncate() without f->sem held, since
171 some pages may be locked and waiting for it in readpage().
172 We are protected from a simultaneous write() extending i_size
173 back past iattr->ia_size, because do_truncate() holds the
174 generic inode semaphore. */
175 if (ivalid & ATTR_SIZE && inode->i_size > iattr->ia_size)
176 vmtruncate(inode, iattr->ia_size);
178 return 0;
181 int jffs2_setattr(struct dentry *dentry, struct iattr *iattr)
183 return jffs2_do_setattr(dentry->d_inode, iattr);
186 int jffs2_statfs(struct super_block *sb, struct kstatfs *buf)
188 struct jffs2_sb_info *c = JFFS2_SB_INFO(sb);
189 unsigned long avail;
191 buf->f_type = JFFS2_SUPER_MAGIC;
192 buf->f_bsize = 1 << PAGE_SHIFT;
193 buf->f_blocks = c->flash_size >> PAGE_SHIFT;
194 buf->f_files = 0;
195 buf->f_ffree = 0;
196 buf->f_namelen = JFFS2_MAX_NAME_LEN;
198 spin_lock(&c->erase_completion_lock);
199 avail = c->dirty_size + c->free_size;
200 if (avail > c->sector_size * c->resv_blocks_write)
201 avail -= c->sector_size * c->resv_blocks_write;
202 else
203 avail = 0;
204 spin_unlock(&c->erase_completion_lock);
206 buf->f_bavail = buf->f_bfree = avail >> PAGE_SHIFT;
208 return 0;
212 void jffs2_clear_inode (struct inode *inode)
214 /* We can forget about this inode for now - drop all
215 * the nodelists associated with it, etc.
217 struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
218 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
220 D1(printk(KERN_DEBUG "jffs2_clear_inode(): ino #%lu mode %o\n", inode->i_ino, inode->i_mode));
222 jffs2_do_clear_inode(c, f);
225 void jffs2_read_inode (struct inode *inode)
227 struct jffs2_inode_info *f;
228 struct jffs2_sb_info *c;
229 struct jffs2_raw_inode latest_node;
230 int ret;
232 D1(printk(KERN_DEBUG "jffs2_read_inode(): inode->i_ino == %lu\n", inode->i_ino));
234 f = JFFS2_INODE_INFO(inode);
235 c = JFFS2_SB_INFO(inode->i_sb);
237 jffs2_init_inode_info(f);
238 down(&f->sem);
240 ret = jffs2_do_read_inode(c, f, inode->i_ino, &latest_node);
242 if (ret) {
243 make_bad_inode(inode);
244 up(&f->sem);
245 return;
247 inode->i_mode = jemode_to_cpu(latest_node.mode);
248 inode->i_uid = je16_to_cpu(latest_node.uid);
249 inode->i_gid = je16_to_cpu(latest_node.gid);
250 inode->i_size = je32_to_cpu(latest_node.isize);
251 inode->i_atime = ITIME(je32_to_cpu(latest_node.atime));
252 inode->i_mtime = ITIME(je32_to_cpu(latest_node.mtime));
253 inode->i_ctime = ITIME(je32_to_cpu(latest_node.ctime));
255 inode->i_nlink = f->inocache->nlink;
257 inode->i_blksize = PAGE_SIZE;
258 inode->i_blocks = (inode->i_size + 511) >> 9;
260 switch (inode->i_mode & S_IFMT) {
261 jint16_t rdev;
263 case S_IFLNK:
264 inode->i_op = &jffs2_symlink_inode_operations;
265 break;
267 case S_IFDIR:
269 struct jffs2_full_dirent *fd;
271 for (fd=f->dents; fd; fd = fd->next) {
272 if (fd->type == DT_DIR && fd->ino)
273 inode->i_nlink++;
275 /* and '..' */
276 inode->i_nlink++;
277 /* Root dir gets i_nlink 3 for some reason */
278 if (inode->i_ino == 1)
279 inode->i_nlink++;
281 inode->i_op = &jffs2_dir_inode_operations;
282 inode->i_fop = &jffs2_dir_operations;
283 break;
285 case S_IFREG:
286 inode->i_op = &jffs2_file_inode_operations;
287 inode->i_fop = &jffs2_file_operations;
288 inode->i_mapping->a_ops = &jffs2_file_address_operations;
289 inode->i_mapping->nrpages = 0;
290 break;
292 case S_IFBLK:
293 case S_IFCHR:
294 /* Read the device numbers from the media */
295 D1(printk(KERN_DEBUG "Reading device numbers from flash\n"));
296 if (jffs2_read_dnode(c, f, f->metadata, (char *)&rdev, 0, sizeof(rdev)) < 0) {
297 /* Eep */
298 printk(KERN_NOTICE "Read device numbers for inode %lu failed\n", (unsigned long)inode->i_ino);
299 up(&f->sem);
300 jffs2_do_clear_inode(c, f);
301 make_bad_inode(inode);
302 return;
305 case S_IFSOCK:
306 case S_IFIFO:
307 inode->i_op = &jffs2_file_inode_operations;
308 init_special_inode(inode, inode->i_mode,
309 old_decode_dev((je16_to_cpu(rdev))));
310 break;
312 default:
313 printk(KERN_WARNING "jffs2_read_inode(): Bogus imode %o for ino %lu\n", inode->i_mode, (unsigned long)inode->i_ino);
316 up(&f->sem);
318 D1(printk(KERN_DEBUG "jffs2_read_inode() returning\n"));
321 void jffs2_dirty_inode(struct inode *inode)
323 struct iattr iattr;
325 if (!(inode->i_state & I_DIRTY_DATASYNC)) {
326 D2(printk(KERN_DEBUG "jffs2_dirty_inode() not calling setattr() for ino #%lu\n", inode->i_ino));
327 return;
330 D1(printk(KERN_DEBUG "jffs2_dirty_inode() calling setattr() for ino #%lu\n", inode->i_ino));
332 iattr.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_MTIME|ATTR_CTIME;
333 iattr.ia_mode = inode->i_mode;
334 iattr.ia_uid = inode->i_uid;
335 iattr.ia_gid = inode->i_gid;
336 iattr.ia_atime = inode->i_atime;
337 iattr.ia_mtime = inode->i_mtime;
338 iattr.ia_ctime = inode->i_ctime;
340 jffs2_do_setattr(inode, &iattr);
343 int jffs2_remount_fs (struct super_block *sb, int *flags, char *data)
345 struct jffs2_sb_info *c = JFFS2_SB_INFO(sb);
347 if (c->flags & JFFS2_SB_FLAG_RO && !(sb->s_flags & MS_RDONLY))
348 return -EROFS;
350 /* We stop if it was running, then restart if it needs to.
351 This also catches the case where it was stopped and this
352 is just a remount to restart it.
353 Flush the writebuffer, if neccecary, else we loose it */
354 if (!(sb->s_flags & MS_RDONLY)) {
355 jffs2_stop_garbage_collect_thread(c);
356 down(&c->alloc_sem);
357 jffs2_flush_wbuf_pad(c);
358 up(&c->alloc_sem);
361 if (!(*flags & MS_RDONLY))
362 jffs2_start_garbage_collect_thread(c);
364 *flags |= MS_NOATIME;
366 return 0;
369 void jffs2_write_super (struct super_block *sb)
371 struct jffs2_sb_info *c = JFFS2_SB_INFO(sb);
372 sb->s_dirt = 0;
374 if (sb->s_flags & MS_RDONLY)
375 return;
377 D1(printk(KERN_DEBUG "jffs2_write_super()\n"));
378 jffs2_garbage_collect_trigger(c);
379 jffs2_erase_pending_blocks(c, 0);
380 jffs2_flush_wbuf_gc(c, 0);
384 /* jffs2_new_inode: allocate a new inode and inocache, add it to the hash,
385 fill in the raw_inode while you're at it. */
386 struct inode *jffs2_new_inode (struct inode *dir_i, int mode, struct jffs2_raw_inode *ri)
388 struct inode *inode;
389 struct super_block *sb = dir_i->i_sb;
390 struct jffs2_sb_info *c;
391 struct jffs2_inode_info *f;
392 int ret;
394 D1(printk(KERN_DEBUG "jffs2_new_inode(): dir_i %ld, mode 0x%x\n", dir_i->i_ino, mode));
396 c = JFFS2_SB_INFO(sb);
398 inode = new_inode(sb);
400 if (!inode)
401 return ERR_PTR(-ENOMEM);
403 f = JFFS2_INODE_INFO(inode);
404 jffs2_init_inode_info(f);
405 down(&f->sem);
407 memset(ri, 0, sizeof(*ri));
408 /* Set OS-specific defaults for new inodes */
409 ri->uid = cpu_to_je16(current->fsuid);
411 if (dir_i->i_mode & S_ISGID) {
412 ri->gid = cpu_to_je16(dir_i->i_gid);
413 if (S_ISDIR(mode))
414 mode |= S_ISGID;
415 } else {
416 ri->gid = cpu_to_je16(current->fsgid);
418 ri->mode = cpu_to_jemode(mode);
419 ret = jffs2_do_new_inode (c, f, mode, ri);
420 if (ret) {
421 make_bad_inode(inode);
422 iput(inode);
423 return ERR_PTR(ret);
425 inode->i_nlink = 1;
426 inode->i_ino = je32_to_cpu(ri->ino);
427 inode->i_mode = jemode_to_cpu(ri->mode);
428 inode->i_gid = je16_to_cpu(ri->gid);
429 inode->i_uid = je16_to_cpu(ri->uid);
430 inode->i_atime = inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC;
431 ri->atime = ri->mtime = ri->ctime = cpu_to_je32(I_SEC(inode->i_mtime));
433 inode->i_blksize = PAGE_SIZE;
434 inode->i_blocks = 0;
435 inode->i_size = 0;
437 insert_inode_hash(inode);
439 return inode;
443 int jffs2_do_fill_super(struct super_block *sb, void *data, int silent)
445 struct jffs2_sb_info *c;
446 struct inode *root_i;
447 int ret;
448 size_t blocks;
450 c = JFFS2_SB_INFO(sb);
452 #ifndef CONFIG_JFFS2_FS_WRITEBUFFER
453 if (c->mtd->type == MTD_NANDFLASH) {
454 printk(KERN_ERR "jffs2: Cannot operate on NAND flash unless jffs2 NAND support is compiled in.\n");
455 return -EINVAL;
457 if (c->mtd->type == MTD_DATAFLASH) {
458 printk(KERN_ERR "jffs2: Cannot operate on DataFlash unless jffs2 DataFlash support is compiled in.\n");
459 return -EINVAL;
461 #endif
463 c->flash_size = c->mtd->size;
464 c->sector_size = c->mtd->erasesize;
465 blocks = c->flash_size / c->sector_size;
468 * Size alignment check
470 if ((c->sector_size * blocks) != c->flash_size) {
471 c->flash_size = c->sector_size * blocks;
472 printk(KERN_INFO "jffs2: Flash size not aligned to erasesize, reducing to %dKiB\n",
473 c->flash_size / 1024);
476 if (c->flash_size < 5*c->sector_size) {
477 printk(KERN_ERR "jffs2: Too few erase blocks (%d)\n", c->flash_size / c->sector_size);
478 return -EINVAL;
481 c->cleanmarker_size = sizeof(struct jffs2_unknown_node);
483 /* NAND (or other bizarre) flash... do setup accordingly */
484 ret = jffs2_flash_setup(c);
485 if (ret)
486 return ret;
488 c->inocache_list = kmalloc(INOCACHE_HASHSIZE * sizeof(struct jffs2_inode_cache *), GFP_KERNEL);
489 if (!c->inocache_list) {
490 ret = -ENOMEM;
491 goto out_wbuf;
493 memset(c->inocache_list, 0, INOCACHE_HASHSIZE * sizeof(struct jffs2_inode_cache *));
495 if ((ret = jffs2_do_mount_fs(c)))
496 goto out_inohash;
498 ret = -EINVAL;
500 D1(printk(KERN_DEBUG "jffs2_do_fill_super(): Getting root inode\n"));
501 root_i = iget(sb, 1);
502 if (is_bad_inode(root_i)) {
503 D1(printk(KERN_WARNING "get root inode failed\n"));
504 goto out_root_i;
507 D1(printk(KERN_DEBUG "jffs2_do_fill_super(): d_alloc_root()\n"));
508 sb->s_root = d_alloc_root(root_i);
509 if (!sb->s_root)
510 goto out_root_i;
512 sb->s_maxbytes = 0xFFFFFFFF;
513 sb->s_blocksize = PAGE_CACHE_SIZE;
514 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
515 sb->s_magic = JFFS2_SUPER_MAGIC;
516 if (!(sb->s_flags & MS_RDONLY))
517 jffs2_start_garbage_collect_thread(c);
518 return 0;
520 out_root_i:
521 iput(root_i);
522 jffs2_free_ino_caches(c);
523 jffs2_free_raw_node_refs(c);
524 if (jffs2_blocks_use_vmalloc(c))
525 vfree(c->blocks);
526 else
527 kfree(c->blocks);
528 out_inohash:
529 kfree(c->inocache_list);
530 out_wbuf:
531 jffs2_flash_cleanup(c);
533 return ret;
536 void jffs2_gc_release_inode(struct jffs2_sb_info *c,
537 struct jffs2_inode_info *f)
539 iput(OFNI_EDONI_2SFFJ(f));
542 struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c,
543 int inum, int nlink)
545 struct inode *inode;
546 struct jffs2_inode_cache *ic;
547 if (!nlink) {
548 /* The inode has zero nlink but its nodes weren't yet marked
549 obsolete. This has to be because we're still waiting for
550 the final (close() and) iput() to happen.
552 There's a possibility that the final iput() could have
553 happened while we were contemplating. In order to ensure
554 that we don't cause a new read_inode() (which would fail)
555 for the inode in question, we use ilookup() in this case
556 instead of iget().
558 The nlink can't _become_ zero at this point because we're
559 holding the alloc_sem, and jffs2_do_unlink() would also
560 need that while decrementing nlink on any inode.
562 inode = ilookup(OFNI_BS_2SFFJ(c), inum);
563 if (!inode) {
564 D1(printk(KERN_DEBUG "ilookup() failed for ino #%u; inode is probably deleted.\n",
565 inum));
567 spin_lock(&c->inocache_lock);
568 ic = jffs2_get_ino_cache(c, inum);
569 if (!ic) {
570 D1(printk(KERN_DEBUG "Inode cache for ino #%u is gone.\n", inum));
571 spin_unlock(&c->inocache_lock);
572 return NULL;
574 if (ic->state != INO_STATE_CHECKEDABSENT) {
575 /* Wait for progress. Don't just loop */
576 D1(printk(KERN_DEBUG "Waiting for ino #%u in state %d\n",
577 ic->ino, ic->state));
578 sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock);
579 } else {
580 spin_unlock(&c->inocache_lock);
583 return NULL;
585 } else {
586 /* Inode has links to it still; they're not going away because
587 jffs2_do_unlink() would need the alloc_sem and we have it.
588 Just iget() it, and if read_inode() is necessary that's OK.
590 inode = iget(OFNI_BS_2SFFJ(c), inum);
591 if (!inode)
592 return ERR_PTR(-ENOMEM);
594 if (is_bad_inode(inode)) {
595 printk(KERN_NOTICE "Eep. read_inode() failed for ino #%u. nlink %d\n",
596 inum, nlink);
597 /* NB. This will happen again. We need to do something appropriate here. */
598 iput(inode);
599 return ERR_PTR(-EIO);
602 return JFFS2_INODE_INFO(inode);
605 unsigned char *jffs2_gc_fetch_page(struct jffs2_sb_info *c,
606 struct jffs2_inode_info *f,
607 unsigned long offset,
608 unsigned long *priv)
610 struct inode *inode = OFNI_EDONI_2SFFJ(f);
611 struct page *pg;
613 pg = read_cache_page(inode->i_mapping, offset >> PAGE_CACHE_SHIFT,
614 (void *)jffs2_do_readpage_unlock, inode);
615 if (IS_ERR(pg))
616 return (void *)pg;
618 *priv = (unsigned long)pg;
619 return kmap(pg);
622 void jffs2_gc_release_page(struct jffs2_sb_info *c,
623 unsigned char *ptr,
624 unsigned long *priv)
626 struct page *pg = (void *)*priv;
628 kunmap(pg);
629 page_cache_release(pg);
632 static int jffs2_flash_setup(struct jffs2_sb_info *c) {
633 int ret = 0;
635 if (jffs2_cleanmarker_oob(c)) {
636 /* NAND flash... do setup accordingly */
637 ret = jffs2_nand_flash_setup(c);
638 if (ret)
639 return ret;
642 /* add setups for other bizarre flashes here... */
643 if (jffs2_nor_ecc(c)) {
644 ret = jffs2_nor_ecc_flash_setup(c);
645 if (ret)
646 return ret;
649 /* and Dataflash */
650 if (jffs2_dataflash(c)) {
651 ret = jffs2_dataflash_setup(c);
652 if (ret)
653 return ret;
656 /* and Intel "Sibley" flash */
657 if (jffs2_nor_wbuf_flash(c)) {
658 ret = jffs2_nor_wbuf_flash_setup(c);
659 if (ret)
660 return ret;
663 return ret;
666 void jffs2_flash_cleanup(struct jffs2_sb_info *c) {
668 if (jffs2_cleanmarker_oob(c)) {
669 jffs2_nand_flash_cleanup(c);
672 /* add cleanups for other bizarre flashes here... */
673 if (jffs2_nor_ecc(c)) {
674 jffs2_nor_ecc_flash_cleanup(c);
677 /* and DataFlash */
678 if (jffs2_dataflash(c)) {
679 jffs2_dataflash_cleanup(c);
682 /* and Intel "Sibley" flash */
683 if (jffs2_nor_wbuf_flash(c)) {
684 jffs2_nor_wbuf_flash_cleanup(c);