From: Christoph Hellwig <h...@lst.de>

Merge these two helpers into the only callers to get rid of some
amazingly bad calling conventions.

Suggested-by: Al Viro <v...@zeniv.linux.org.uk>
Signed-off-by: Christoph Hellwig <h...@lst.de>
Signed-off-by: Richard Weinberger <rich...@nod.at>
---
 cpukit/libfs/src/jffs2/src/fs-rtems.c | 24 ------------------
 cpukit/libfs/src/jffs2/src/gc.c       | 35 +++++++++++++++++++++------
 cpukit/libfs/src/jffs2/src/os-rtems.h |  3 ---
 3 files changed, 27 insertions(+), 35 deletions(-)

diff --git a/cpukit/libfs/src/jffs2/src/fs-rtems.c 
b/cpukit/libfs/src/jffs2/src/fs-rtems.c
index 8bc3d85cc3..b863c74547 100644
--- a/cpukit/libfs/src/jffs2/src/fs-rtems.c
+++ b/cpukit/libfs/src/jffs2/src/fs-rtems.c
@@ -1316,30 +1316,6 @@ int rtems_jffs2_initialize(
 //
 //==========================================================================
 
-unsigned char *jffs2_gc_fetch_page(struct jffs2_sb_info *c, 
-                                  struct jffs2_inode_info *f, 
-                                  unsigned long offset,
-                                  unsigned long *priv)
-{
-       int ret;
-       struct super_block *sb = OFNI_BS_2SFFJ(c);
-       unsigned char *gc_buffer = &sb->s_gc_buffer[0];
-
-       ret = jffs2_read_inode_range(c, f, gc_buffer, 
-                                    offset & ~(PAGE_CACHE_SIZE-1), 
PAGE_CACHE_SIZE);
-       if (ret)
-               return ERR_PTR(ret);
-
-       return gc_buffer;
-}
-
-void jffs2_gc_release_page(struct jffs2_sb_info *c,
-                          unsigned char *ptr,
-                          unsigned long *priv)
-{
-       /* Do nothing */
-}
-
 static struct _inode *new_inode(struct super_block *sb)
 {
 
diff --git a/cpukit/libfs/src/jffs2/src/gc.c b/cpukit/libfs/src/jffs2/src/gc.c
index f557075ab8..04ec073d2b 100644
--- a/cpukit/libfs/src/jffs2/src/gc.c
+++ b/cpukit/libfs/src/jffs2/src/gc.c
@@ -1173,12 +1173,17 @@ static int jffs2_garbage_collect_dnode(struct 
jffs2_sb_info *c, struct jffs2_era
                                       struct jffs2_inode_info *f, struct 
jffs2_full_dnode *fn,
                                       uint32_t start, uint32_t end)
 {
+#ifndef __rtems__
+       struct inode *inode = OFNI_EDONI_2SFFJ(f);
+#endif /* __rtems__ */
        struct jffs2_full_dnode *new_fn;
        struct jffs2_raw_inode ri;
        uint32_t alloclen, offset, orig_end, orig_start;
        int ret = 0;
        unsigned char *comprbuf = NULL, *writebuf;
-       unsigned long pg;
+#ifndef __rtems__
+       struct page *page;
+#endif /* __rtems__ */
        unsigned char *pg_ptr;
 
        memset(&ri, 0, sizeof(ri));
@@ -1333,15 +1338,26 @@ static int jffs2_garbage_collect_dnode(struct 
jffs2_sb_info *c, struct jffs2_era
         * end up here trying to GC the *same* page that jffs2_write_begin() is
         * trying to write out, read_cache_page() will not deadlock. */
        mutex_unlock(&f->sem);
-       pg_ptr = jffs2_gc_fetch_page(c, f, start, &pg);
-       mutex_lock(&f->sem);
-
-       if (IS_ERR(pg_ptr)) {
+#ifndef __rtems__
+       page = read_cache_page(inode->i_mapping, start >> PAGE_SHIFT,
+                              jffs2_do_readpage_unlock, inode);
+       if (IS_ERR(page)) {
                pr_warn("read_cache_page() returned error: %ld\n",
-                       PTR_ERR(pg_ptr));
-               return PTR_ERR(pg_ptr);
+                       PTR_ERR(page));
+               mutex_lock(&f->sem);
+               return PTR_ERR(page);
        }
 
+       pg_ptr = kmap(page);
+#else /* __rtems__ */
+       pg_ptr = &OFNI_BS_2SFFJ(c)->s_gc_buffer[0];
+       ret = jffs2_read_inode_range(c, f, pg_ptr,
+                                    start & ~(PAGE_CACHE_SIZE-1), 
PAGE_CACHE_SIZE);
+       if (ret)
+               return ret;
+#endif /* __rtems__ */
+       mutex_lock(&f->sem);
+
        offset = start;
        while(offset < orig_end) {
                uint32_t datalen;
@@ -1404,6 +1420,9 @@ static int jffs2_garbage_collect_dnode(struct 
jffs2_sb_info *c, struct jffs2_era
                }
        }
 
-       jffs2_gc_release_page(c, pg_ptr, &pg);
+#ifndef __rtems__
+       kunmap(page);
+       put_page(page);
+#endif /* __rtems__ */
        return ret;
 }
diff --git a/cpukit/libfs/src/jffs2/src/os-rtems.h 
b/cpukit/libfs/src/jffs2/src/os-rtems.h
index 0bec517691..d9e4330371 100644
--- a/cpukit/libfs/src/jffs2/src/os-rtems.h
+++ b/cpukit/libfs/src/jffs2/src/os-rtems.h
@@ -136,9 +136,6 @@ struct _inode *jffs2_iget(struct super_block *sb, 
cyg_uint32 ino);
 void jffs2_iput(struct _inode * i);
 void jffs2_gc_release_inode(struct jffs2_sb_info *c, struct jffs2_inode_info 
*f);
 struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c, int 
inum, int nlink);
-unsigned char *jffs2_gc_fetch_page(struct jffs2_sb_info *c, struct 
jffs2_inode_info *f, 
-                                  unsigned long offset, unsigned long *priv);
-void jffs2_gc_release_page(struct jffs2_sb_info *c, unsigned char *pg, 
unsigned long *priv);
 
 /* Avoid polluting RTEMS namespace with names not starting in jffs2_ */
 #define os_to_jffs2_mode(x) jffs2_from_os_mode(x)
-- 
2.35.3

_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to