Skip to contentSkip to conversation

mics cleanups for mtd

PATCH In review Adrian Bunk 2 participants 4 messages Jan 19, 2003 – Jan 20, 2003

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mics cleanups for mtd

Below is a cleanup for mtd:

I started with removing all #if'd code for kernels < 2.4.4.

After this cleanup linux/mtd/compatmac.h contained only #include's so I completely removed this file, removed all #include's of it in both the mtd and jffs2 (sic) code and added the few needed #include's in the .c files.

Besides this I removed a few #include <stdarg.h>.

I've tested the compilation with 2.5.59.

diffstat output:

 drivers/mtd/chips/cfi_cmdset_0001.c |    1 
 drivers/mtd/chips/chipreg.c         |    1 
 drivers/mtd/chips/jedec.c           |    1 
 drivers/mtd/chips/map_absent.c      |    1 
 drivers/mtd/chips/map_ram.c         |    1 
 drivers/mtd/chips/map_rom.c         |    1 
 drivers/mtd/devices/blkmtd.c        |   41 -------
 drivers/mtd/devices/doc1000.c       |    1 
 drivers/mtd/devices/docecc.c        |    1 
 drivers/mtd/devices/mtdram.c        |    3 
 drivers/mtd/devices/pmc551.c        |    6 -
 drivers/mtd/devices/slram.c         |    1 
 drivers/mtd/ftl.c                   |    8 -
 drivers/mtd/maps/l440gx.c           |    1 
 drivers/mtd/maps/netsc520.c         |    1 
 drivers/mtd/maps/pcmciamtd.c        |    1 
 drivers/mtd/maps/physmap.c          |    1 
 drivers/mtd/maps/pnc2000.c          |    1 
 drivers/mtd/maps/sc520cdp.c         |    1 
 drivers/mtd/maps/scx200_docflash.c  |    1 
 drivers/mtd/mtdblock.c              |    8 -
 drivers/mtd/mtdblock_ro.c           |    1 
 drivers/mtd/mtdchar.c               |    1 
 drivers/mtd/mtdcore.c               |   35 ------
 drivers/mtd/nftlcore.c              |    1 
 drivers/mtd/nftlmount.c             |    1 
 fs/jffs2/background.c               |    1 
 fs/jffs2/build.c                    |    1 
 fs/jffs2/compr_zlib.c               |    3 
 fs/jffs2/dir.c                      |    1 
 fs/jffs2/file.c                     |    1 
 fs/jffs2/nodelist.h                 |    1 
 include/linux/mtd/cfi.h             |    2 
 include/linux/mtd/compatmac.h       |  203 ------------------------------------
 include/linux/mtd/mtd.h             |    1 
 35 files changed, 25 insertions(+), 310 deletions(-)

cu
Adrian

include/linux/mtd/compatmac.h deleted +0 -203
@@ -1,203 +0,0 @@
-
-/*
- * mtd/include/compatmac.h
- *
- * $Id: compatmac.h,v 1.4 2000/07/03 10:01:38 dwmw2 Exp $
- *
- * Extensions and omissions from the normal 'linux/compatmac.h'
- * files. hopefully this will end up empty as the 'real' one 
- * becomes fully-featured.
- */
-
-
-/* First, include the parts which the kernel is good enough to provide 
- * to us 
- */
-   
-#ifndef __LINUX_MTD_COMPATMAC_H__
-#define __LINUX_MTD_COMPATMAC_H__
-
-#include <linux/compatmac.h>
-#include <linux/types.h> /* used later in this header */
-#include <linux/module.h>
-#ifndef LINUX_VERSION_CODE
-#include <linux/version.h>
-#endif
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
-#include <linux/vmalloc.h>
-#endif
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,0,0)
-#  error "This kernel is too old: not supported by this file"
-#endif
-
-/* Modularization issues */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,18)
-#  define __USE_OLD_SYMTAB__
-#  define EXPORT_NO_SYMBOLS register_symtab(NULL);
-#  define REGISTER_SYMTAB(tab) register_symtab(tab)
-#else
-#  define REGISTER_SYMTAB(tab) /* nothing */
-#endif
-
-#ifdef __USE_OLD_SYMTAB__
-#  define __MODULE_STRING(s)         /* nothing */
-#  define MODULE_PARM(v,t)           /* nothing */
-#  define MODULE_PARM_DESC(v,t)      /* nothing */
-#  define MODULE_AUTHOR(n)           /* nothing */
-#  define MODULE_DESCRIPTION(d)      /* nothing */
-#  define MODULE_SUPPORTED_DEVICE(n) /* nothing */
-#endif
-
-/*
- * "select" changed in 2.1.23. The implementation is twin, but this
- * header is new
- */
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,1,22)
-#  include <linux/poll.h>
-#else
-#  define __USE_OLD_SELECT__
-#endif
-
-/* Other change in the fops are solved using pseudo-types */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
-#  define lseek_t      long long
-#  define lseek_off_t  long long
-#else
-#  define lseek_t      int
-#  define lseek_off_t  off_t
-#endif
-
-/* changed the prototype of read/write */
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0) || defined(__alpha__)
-# define count_t unsigned long
-# define read_write_t long
-#else
-# define count_t int
-# define read_write_t int
-#endif
-
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,31)
-# define release_t void
-#  define release_return(x) return
-#else
-#  define release_t int
-#  define release_return(x) return (x)
-#endif
-
-#if LINUX_VERSION_CODE < 0x20300
-#define __exit
-#endif
-#if LINUX_VERSION_CODE < 0x20200
-#define __init
-#else
-#include <linux/init.h>
-#endif
-
-#if LINUX_VERSION_CODE < 0x20300
-#define init_MUTEX(x) do {*(x) = MUTEX;} while (0)
-#define RQFUNC_ARG void
-#define blkdev_dequeue_request(req) do {CURRENT = req->next;} while (0)
-#else
-#define RQFUNC_ARG request_queue_t *q
-#endif
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,0)
-#define __MOD_INC_USE_COUNT(mod)                                        \
-        (atomic_inc(&(mod)->uc.usecount), (mod)->flags |= MOD_VISITED|MOD_USED_ONCE)
-#define __MOD_DEC_USE_COUNT(mod)                                        \
-        (atomic_dec(&(mod)->uc.usecount), (mod)->flags |= MOD_VISITED)
-#endif
-
-
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
-
-#define DECLARE_WAIT_QUEUE_HEAD(x) struct wait_queue *x = NULL
-#define init_waitqueue_head init_waitqueue
-
-static inline int try_inc_mod_count(struct module *mod)
-{
-	if (mod)
-		__MOD_INC_USE_COUNT(mod);
-	return 1;
-}
-#endif
-
-
-/* Yes, I'm aware that it's a fairly ugly hack.
-   Until the __constant_* macros appear in Linus' own kernels, this is
-   the way it has to be done.
- DW 19/1/00
- */
-
-#include <asm/byteorder.h>
-
-#ifndef __constant_cpu_to_le16
-
-#ifdef __BIG_ENDIAN
-#define __constant_cpu_to_le64(x) ___swab64((x))
-#define __constant_le64_to_cpu(x) ___swab64((x))
-#define __constant_cpu_to_le32(x) ___swab32((x))
-#define __constant_le32_to_cpu(x) ___swab32((x))
-#define __constant_cpu_to_le16(x) ___swab16((x))
-#define __constant_le16_to_cpu(x) ___swab16((x))
-#define __constant_cpu_to_be64(x) ((__u64)(x))
-#define __constant_be64_to_cpu(x) ((__u64)(x))
-#define __constant_cpu_to_be32(x) ((__u32)(x))
-#define __constant_be32_to_cpu(x) ((__u32)(x))
-#define __constant_cpu_to_be16(x) ((__u16)(x))
-#define __constant_be16_to_cpu(x) ((__u16)(x))
-#else
-#ifdef __LITTLE_ENDIAN
-#define __constant_cpu_to_le64(x) ((__u64)(x))
-#define __constant_le64_to_cpu(x) ((__u64)(x))
-#define __constant_cpu_to_le32(x) ((__u32)(x))
-#define __constant_le32_to_cpu(x) ((__u32)(x))
-#define __constant_cpu_to_le16(x) ((__u16)(x))
-#define __constant_le16_to_cpu(x) ((__u16)(x))
-#define __constant_cpu_to_be64(x) ___swab64((x))
-#define __constant_be64_to_cpu(x) ___swab64((x))
-#define __constant_cpu_to_be32(x) ___swab32((x))
-#define __constant_be32_to_cpu(x) ___swab32((x))
-#define __constant_cpu_to_be16(x) ___swab16((x))
-#define __constant_be16_to_cpu(x) ___swab16((x))
-#else
-#error No (recognised) endianness defined (unless it,s PDP)
-#endif /* __LITTLE_ENDIAN */
-#endif /* __BIG_ENDIAN */
-
-#endif /* ifndef __constant_cpu_to_le16 */
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
-  #define mod_init_t int  __init
-  #define mod_exit_t void  
-#else
-  #define mod_init_t static int __init
-  #define mod_exit_t static void __exit
-#endif
-
-#ifndef THIS_MODULE
-#ifdef MODULE
-#define THIS_MODULE (&__this_module)
-#else
-#define THIS_MODULE (NULL)
-#endif
-#endif
-
-#if LINUX_VERSION_CODE < 0x20300
-#include <linux/interrupt.h>
-#define spin_lock_bh(lock) do {start_bh_atomic();spin_lock(lock);} while(0)
-#define spin_unlock_bh(lock) do {spin_unlock(lock);end_bh_atomic();} while(0)
-#else
-#include <linux/interrupt.h>
-#include <asm/softirq.h>
-#include <linux/spinlock.h>
-#endif
-
-#endif /* __LINUX_MTD_COMPATMAC_H__ */
-
-
include/linux/mtd/mtd.h renamed from include/linux/mtd/mtd.h.old +0 -1
@@ -9,7 +9,6 @@
 #include <linux/config.h>
 #include <linux/version.h>
 #include <linux/types.h>
-#include <linux/mtd/compatmac.h>
 #include <linux/module.h>
 #include <linux/uio.h>
 
include/linux/mtd/cfi.h renamed from include/linux/mtd/cfi.h.old +0 -2
@@ -367,7 +367,6 @@
 
 static inline void cfi_udelay(int us)
 {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
 	if (need_resched()) {
 		unsigned long t = us * HZ / 1000000;
 		if (t < 1)
@@ -376,7 +375,6 @@
 		schedule_timeout(t);
 	}
 	else
-#endif
 		udelay(us);
 }
 static inline void cfi_spin_lock(spinlock_t *mutex)
drivers/mtd/devices/docecc.c renamed from drivers/mtd/devices/docecc.c.old +0 -1
@@ -36,7 +36,6 @@
 #include <linux/init.h>
 #include <linux/types.h>
 
-#include <linux/mtd/compatmac.h> /* for min() in older kernels */
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/doc2000.h>
 
drivers/mtd/devices/blkmtd.c renamed from drivers/mtd/devices/blkmtd.c.old +0 -41

101 lines not on this page · raw message

drivers/mtd/nftlcore.c renamed from drivers/mtd/nftlcore.c.old +0 -1
@@ -31,7 +31,6 @@
 #endif
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/nftl.h>
-#include <linux/mtd/compatmac.h>
 
 /* maximum number of loops while examining next block, to have a
    chance to detect consistency problems (they should never happen
drivers/mtd/nftlmount.c renamed from drivers/mtd/nftlmount.c.old +0 -1
@@ -35,7 +35,6 @@
 #include <linux/init.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/nftl.h>
-#include <linux/mtd/compatmac.h>
 
 #define SECTORSIZE 512
 
drivers/mtd/chips/cfi_cmdset_0001.c renamed from drivers/mtd/chips/cfi_cmdset_0001.c.old +0 -1
@@ -28,7 +28,6 @@
 #include <linux/interrupt.h>
 #include <linux/mtd/map.h>
 #include <linux/mtd/cfi.h>
-#include <linux/mtd/compatmac.h>
 
 static int cfi_intelext_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
 static int cfi_intelext_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
drivers/mtd/chips/chipreg.c renamed from drivers/mtd/chips/chipreg.c.old +0 -1
@@ -9,7 +9,6 @@
 #include <linux/config.h>
 #include <linux/kmod.h>
 #include <linux/spinlock.h>
-#include <linux/mtd/compatmac.h>
 #include <linux/mtd/map.h>
 
 spinlock_t chip_drvs_lock = SPIN_LOCK_UNLOCKED;
drivers/mtd/mtdblock_ro.c renamed from drivers/mtd/mtdblock_ro.c.old +0 -1
@@ -14,7 +14,6 @@
 #include <linux/types.h>
 
 #include <linux/mtd/mtd.h>
-#include <linux/mtd/compatmac.h>
 #include <linux/buffer_head.h>
 #include <linux/genhd.h>
 
fs/jffs2/background.c renamed from fs/jffs2/background.c.old +0 -1
@@ -18,7 +18,6 @@
 #include <linux/mtd/mtd.h>
 #include <linux/interrupt.h>
 #include <linux/completion.h>
-#include <linux/mtd/compatmac.h> /* recalc_sigpending() */
 #include <linux/unistd.h>
 #include "nodelist.h"
 
fs/jffs2/dir.c renamed from fs/jffs2/dir.c.old +0 -1
@@ -16,7 +16,6 @@
 #include <linux/sched.h>
 #include <linux/fs.h>
 #include <linux/crc32.h>
-#include <linux/mtd/compatmac.h> /* For completion */
 #include <linux/jffs2.h>
 #include <linux/jffs2_fs_i.h>
 #include <linux/jffs2_fs_sb.h>
fs/jffs2/file.c renamed from fs/jffs2/file.c.old +0 -1
@@ -12,7 +12,6 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/mtd/compatmac.h> /* for min() */
 #include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/time.h>
fs/jffs2/nodelist.h renamed from fs/jffs2/nodelist.h.old +0 -1
@@ -17,7 +17,6 @@
 #include <linux/config.h>
 #include <linux/fs.h>
 
-#include <linux/mtd/compatmac.h> /* For min/max in older kernels */
 #include <linux/jffs2.h>
 #include <linux/jffs2_fs_sb.h>
 #include <linux/jffs2_fs_i.h>
fs/jffs2/compr_zlib.c renamed from fs/jffs2/compr_zlib.c.old +2 -1
@@ -17,10 +17,11 @@
 
 #include <linux/config.h>
 #include <linux/kernel.h>
-#include <linux/mtd/compatmac.h> /* for min() */
 #include <linux/slab.h>
 #include <linux/jffs2.h>
 #include <linux/zlib.h>
+#include <linux/init.h>
+#include <linux/vmalloc.h>
 #include "nodelist.h"
 
 	/* Plan: call deflate() with avail_in == *sourcelen, 
fs/jffs2/build.c renamed from fs/jffs2/build.c.old +1 -0
@@ -13,6 +13,7 @@
 
 #include <linux/kernel.h>
 #include <linux/slab.h>
+#include <linux/sched.h>
 #include "nodelist.h"
 
 int jffs2_build_inode_pass1(struct jffs2_sb_info *, struct jffs2_inode_cache *);
drivers/mtd/chips/jedec.c renamed from drivers/mtd/chips/jedec.c.old +1 -0
@@ -15,6 +15,7 @@
  */
 
 #include <linux/mtd/jedec.h>
+#include <linux/init.h>
 
 static struct mtd_info *jedec_probe(struct map_info *);
 static int jedec_probe8(struct map_info *map,unsigned long base,
drivers/mtd/chips/map_ram.c renamed from drivers/mtd/chips/map_ram.c.old +1 -0
@@ -11,6 +11,7 @@
 #include <asm/byteorder.h>
 #include <linux/errno.h>
 #include <linux/slab.h>
+#include <linux/init.h>
 
 #include <linux/mtd/map.h>
 
drivers/mtd/chips/map_rom.c renamed from drivers/mtd/chips/map_rom.c.old +1 -0
@@ -12,6 +12,7 @@
 #include <asm/byteorder.h>
 #include <linux/errno.h>
 #include <linux/slab.h>
+#include <linux/init.h>
 
 #include <linux/mtd/map.h>
 
drivers/mtd/chips/map_absent.c renamed from drivers/mtd/chips/map_absent.c.old +1 -0
@@ -23,6 +23,7 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/slab.h>
+#include <linux/init.h>
 
 #include <linux/mtd/map.h>
 
drivers/mtd/devices/mtdram.c renamed from drivers/mtd/devices/mtdram.c.old +2 -1
@@ -13,7 +13,8 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/ioport.h>
-#include <linux/mtd/compatmac.h>
+#include <linux/init.h>
+#include <linux/vmalloc.h>
 #include <linux/mtd/mtd.h>
 
 #ifndef CONFIG_MTDRAM_ABS_POS
drivers/mtd/maps/l440gx.c renamed from drivers/mtd/maps/l440gx.c.old +1 -0
@@ -11,6 +11,7 @@
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/map.h>
 #include <linux/config.h>
+#include <linux/init.h>
 
 
 #define WINDOW_ADDR 0xfff00000
drivers/mtd/maps/physmap.c renamed from drivers/mtd/maps/physmap.c.old +1 -0
@@ -11,6 +11,7 @@
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/map.h>
 #include <linux/config.h>
+#include <linux/init.h>
 
 
 #define WINDOW_ADDR CONFIG_MTD_PHYSMAP_START
drivers/mtd/maps/pnc2000.c renamed from drivers/mtd/maps/pnc2000.c.old +1 -0
@@ -11,6 +11,7 @@
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
+#include <linux/init.h>
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/map.h>
drivers/mtd/maps/pcmciamtd.c renamed from drivers/mtd/maps/pcmciamtd.c.old +1 -0
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/timer.h>
+#include <linux/init.h>
 #include <asm/io.h>
 #include <asm/system.h>
 
drivers/mtd/maps/sc520cdp.c renamed from drivers/mtd/maps/sc520cdp.c.old +1 -0
@@ -28,6 +28,7 @@
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
+#include <linux/init.h>
 #include <asm/io.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/map.h>
drivers/mtd/maps/netsc520.c renamed from drivers/mtd/maps/netsc520.c.old +1 -0
@@ -27,6 +27,7 @@
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
+#include <linux/init.h>
 #include <asm/io.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/map.h>
drivers/mtd/maps/scx200_docflash.c renamed from drivers/mtd/maps/scx200_docflash.c.old +1 -0
@@ -9,6 +9,7 @@
 #include <linux/config.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
+#include <linux/init.h>
 #include <asm/io.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/map.h>
drivers/mtd/mtdcore.c renamed from drivers/mtd/mtdcore.c.old +1 -34
@@ -17,8 +17,7 @@
 #include <linux/major.h>
 #include <linux/fs.h>
 #include <linux/ioctl.h>
-#include <stdarg.h>
-#include <linux/mtd/compatmac.h>
+#include <linux/init.h>
 #ifdef CONFIG_PROC_FS
 #include <linux/proc_fs.h>
 #endif
@@ -247,9 +246,7 @@
 
 #ifdef CONFIG_PROC_FS
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
 static struct proc_dir_entry *proc_mtd;
-#endif
 
 static inline int mtd_proc_info (char *buf, int i)
 {
@@ -263,11 +260,7 @@
 }
 
 static int mtd_read_proc ( char *page, char **start, off_t off,int count
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
                        ,int *eof, void *data_unused
-#else
-                        ,int unused
-#endif
 			)
 {
 	int len, l, i;
@@ -288,9 +281,7 @@
                 }
         }
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
         *eof = 1;
-#endif
 
 done:
 	up(&mtd_table_mutex);
@@ -300,18 +291,6 @@
         return ((count < begin+len-off) ? count : begin+len-off);
 }
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,0)
-struct proc_dir_entry mtd_proc_entry = {
-        0,                 /* low_ino: the inode -- dynamic */
-        3, "mtd",     /* len of name and name */
-        S_IFREG | S_IRUGO, /* mode */
-        1, 0, 0,           /* nlinks, owner, group */
-        0, NULL,           /* size - unused; operations -- use default */
-        &mtd_read_proc,   /* function used to read data */
-        /* nothing more */
-    };
-#endif
-
 #endif /* CONFIG_PROC_FS */
 
 /*====================================================================*/
@@ -320,16 +299,8 @@
 int __init init_mtd(void)
 {
 #ifdef CONFIG_PROC_FS
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
 	if ((proc_mtd = create_proc_entry( "mtd", 0, 0 )))
 	  proc_mtd->read_proc = mtd_read_proc;
-#else
-        proc_register_dynamic(&proc_root,&mtd_proc_entry);
-#endif
-#endif
-
-#if LINUX_VERSION_CODE < 0x20212
-	init_mtd_devices();
 #endif
 
 #ifdef CONFIG_PM
@@ -348,12 +319,8 @@
 #endif
 
 #ifdef CONFIG_PROC_FS
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
         if (proc_mtd)
           remove_proc_entry( "mtd", 0);
-#else
-        proc_unregister(&proc_root,mtd_proc_entry.low_ino);
-#endif
 #endif
 }
 
drivers/mtd/mtdchar.c renamed from drivers/mtd/mtdchar.c.old +1 -0
@@ -12,6 +12,7 @@
 #include <linux/mtd/mtd.h>
 #include <linux/smp_lock.h>
 #include <linux/slab.h>
+#include <linux/init.h>
 
 #ifdef CONFIG_DEVFS_FS
 #include <linux/devfs_fs_kernel.h>
drivers/mtd/devices/slram.c renamed from drivers/mtd/devices/slram.c.old +0 -1
@@ -20,7 +20,6 @@
 #include <linux/init.h>
 #include <asm/io.h>
 #include <asm/system.h>
-#include <stdarg.h>
 
 #include <linux/mtd/mtd.h>
 
drivers/mtd/devices/doc1000.c renamed from drivers/mtd/devices/doc1000.c.old +0 -1
@@ -20,7 +20,6 @@
 #include <linux/ioctl.h>
 #include <asm/io.h>
 #include <asm/system.h>
-#include <stdarg.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 
drivers/mtd/devices/pmc551.c renamed from drivers/mtd/devices/pmc551.c.old +0 -6
@@ -98,7 +98,6 @@
 #include <linux/ioctl.h>
 #include <asm/io.h>
 #include <asm/system.h>
-#include <stdarg.h>
 #include <linux/pci.h>
 
 #ifndef CONFIG_PCI
@@ -107,13 +106,8 @@
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/pmc551.h>
-#include <linux/mtd/compatmac.h>
 
-#if LINUX_VERSION_CODE > 0x20300
 #define PCI_BASE_ADDRESS(dev) (dev->resource[0].start)
-#else
-#define PCI_BASE_ADDRESS(dev) (dev->base_address[0])
-#endif
 
 static struct mtd_info *pmc551list;
 
drivers/mtd/ftl.c renamed from drivers/mtd/ftl.c.old +3 -5
@@ -56,7 +56,6 @@
       
 ======================================================================*/
 #include <linux/module.h>
-#include <linux/mtd/compatmac.h>
 #include <linux/mtd/mtd.h>
 /*#define PSYCHO_DEBUG */
 
@@ -70,7 +69,6 @@
 #include <linux/fs.h>
 #include <linux/ioctl.h>
 #include <linux/hdreg.h>
-#include <stdarg.h>
 
 #include <linux/vmalloc.h>
 #include <linux/blkpg.h>
@@ -174,7 +172,7 @@
 static int ftl_ioctl(struct inode *inode, struct file *file,
 		     u_int cmd, u_long arg);
 static int ftl_open(struct inode *inode, struct file *file);
-static release_t ftl_close(struct inode *inode, struct file *file);
+static int ftl_close(struct inode *inode, struct file *file);
 static int ftl_revalidate(struct gendisk *disk);
 
 static void ftl_erase_callback(struct erase_info *done);
@@ -850,7 +848,7 @@
 
 /*====================================================================*/
 
-static release_t ftl_close(struct inode *inode, struct file *file)
+static int ftl_close(struct inode *inode, struct file *file)
 {
 	partition_t *part = inode->i_bdev->bd_disk->private_data;
 	int i;
@@ -869,7 +867,7 @@
 	atomic_dec(&part->open);
 
 	put_mtd_device(part->mtd);
-	release_return(0);
+	return(0);
 } /* ftl_close */
 
 
drivers/mtd/mtdblock.c renamed from drivers/mtd/mtdblock.c.old +4 -4
@@ -13,8 +13,8 @@
 #include <linux/slab.h>
 #include <linux/buffer_head.h>
 #include <linux/mtd/mtd.h>
-#include <linux/mtd/compatmac.h>
 #include <linux/buffer_head.h>
+#include <linux/vmalloc.h>
 
 #define MAJOR_NR MTD_BLOCK_MAJOR
 #define DEVICE_NAME "mtdblock"
@@ -338,14 +338,14 @@
 	return -ENOMEM;
 }
 
-static release_t mtdblock_release(struct inode *inode, struct file *file)
+static int mtdblock_release(struct inode *inode, struct file *file)
 {
 	int dev;
 	struct mtdblk_dev *mtdblk;
    	DEBUG(MTD_DEBUG_LEVEL1, "mtdblock_release\n");
 
 	if (inode == NULL)
-		release_return(-ENODEV);
+		return(-ENODEV);
 
 	dev = minor(inode->i_rdev);
 	mtdblk = mtdblks[dev];
@@ -370,7 +370,7 @@
 
 	DEBUG(MTD_DEBUG_LEVEL1, "ok\n");
 
-	release_return(0);
+	return(0);
 }  
 
 
maintainer
#1 lore raw
Quoted 3 lines · Adrian Bunk

Below is a cleanup for mtd:

I started with removing all #if'd code for kernels < 2.4.4.

That's a reasonable idea, I suppose -- I haven't had someone bitch about me breaking the 2.2 uClinux build for a while now. I want to go further than that with the block device drivers -- they'll be completely forked for 2.4/2.5 support because it's just too ugly to try to support both.

For most of the other code, the pain of maintaining two separate versions just isn't justified by the marginal cleanup which this affords -- especially for the drivers where the _only_ difference between building out-of-the-box in 2.4 and not doing so is a #include <linux/mtd/compatmac.h>

Quoted 4 lines

After this cleanup linux/mtd/compatmac.h contained only #include's so I completely removed this file, removed all #include's of it in both the mtd and jffs2 (sic) code and added the few needed #include's in the .c files.

You misunderstand the purpose of this. The idea is that the code itself can be written for the latest kernel, but people can use it on older kernels and compatmac.h makes it OK. If you remove the #include compatmac.h then that doesn't work; obviously :)

The extra #include does no harm -- do not remove it. Removing everything from compatmac.h in 2.5 is OK though; just leave it almost empty (but with the #ifdef guard to prevent GCC from reading it more than once).

Adding the include files which were indirectly included through compatmac.h is also OK -- we can just 'touch' those to make it build with older kernels; they weren't intentionally omitted.

Quoted 1 line

Besides this I removed a few #include <stdarg.h>.

OK.

Signature · 1 line
dwmw2
#2 lore raw
Quoted 11 lines · David Woodhouse
Quoted 3 lines · Adrian Bunk

Below is a cleanup for mtd:

I started with removing all #if'd code for kernels < 2.4.4.

That's a reasonable idea, I suppose -- I haven't had someone bitch about me breaking the 2.2 uClinux build for a while now. I want to go further than that with the block device drivers -- they'll be completely forked for 2.4/2.5 support because it's just too ugly to try to support both.

Quoted 4 lines

For most of the other code, the pain of maintaining two separate versions just isn't justified by the marginal cleanup which this affords -- especially for the drivers where the _only_ difference between building out-of-the-box in 2.4 and not doing so is a #include <linux/mtd/compatmac.h>

The #include <linux/mtd/compatmac.h> has _no_ effect for building on 2.4 kernels, it only affects 2.0 and 2.2 kernels.

The only reason why I said kernels < 2.4.4 is that I removed some
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,4)
from drivers/mtd/devices/blkmtd.c.

If you want to support the kernels 2.4.0, 2.4.1, 2.4.2 and 2.4.3 these should be kept, but linux/mtd/compatmac.h is not needed for this.

Quoted 9 lines
Quoted 4 lines

After this cleanup linux/mtd/compatmac.h contained only #include's so I completely removed this file, removed all #include's of it in both the mtd and jffs2 (sic) code and added the few needed #include's in the .c files.

You misunderstand the purpose of this. The idea is that the code itself can be written for the latest kernel, but people can use it on older kernels and compatmac.h makes it OK. If you remove the #include compatmac.h then that doesn't work; obviously :)

I can send whatever patch you want.

What is the minimum kernel version you want to support:
- 2.0.0
- 2.2.0
- 2.4.0
- 2.4.4

Quoted 4 lines

...
Adding the include files which were indirectly included through compatmac.h is also OK -- we can just 'touch' those to make it build with older kernels; they weren't intentionally omitted.

I haven't checked older kernels but at least kernel 2.2.20 includes all header files I've added (init.h, sched.h, vmalloc.h).

Quoted 2 lines

...
dwmw2

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
maintainer
#3 lore raw
Quoted 8 lines · Adrian Bunk
Quoted 4 lines · David Woodhouse

For most of the other code, the pain of maintaining two separate versions just isn't justified by the marginal cleanup which this affords -- especially for the drivers where the _only_ difference between building out-of-the-box in 2.4 and not doing so is a #include <linux/mtd/compatmac.h>

The #include <linux/mtd/compatmac.h> has _no_ effect for building on 2.4 kernels, it only affects 2.0 and 2.2 kernels.

The mtd/compatmac.h in the 2.5 kernel tree has no effect for building on 2.4 kernels, true. That's because I haven't bothered to update the version in Linus' tree -- as you observed, it has no effect there.

To take a random example -- when I changed the JFFS2 code to use PageUptodate() instead of Page_Uptodate(), I also added this to mtd/compatmac.h in CVS:

	#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,12)
	#define PageUptodate(x) Page_Uptodate(x)
	#endif

However, there was no point in sending that part of the change to Linus for the 2.5 kernel -- it's pointless there. That's why you see no compatibility code _IN THE 2.5 TREE_ for older trees.

The mtd/compatmac.h in the CVS tree, however, makes the 2.5-specific code actually build and work on 2.4 and earlier kernels -- and removing the #include of it is not helpful.

Quoted 3 lines

The only reason why I said kernels < 2.4.4 is that I removed some
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,4)
from drivers/mtd/devices/blkmtd.c.

The author of blkmtd.c recently rewrote it completely for 2.5 -- the ifdefs in there were getting so ugly it was worth forking it.

The same treatment is appropriate for the block device drivers too -- mtdblock is done, and once ftl and nftl are also done I'll be sending them to Linus. If you really want to help, your assistance would be very much appreciated in forking those drivers in the CVS tree into 2.5-specific and older versions.

Quoted 1 line

I can send whatever patch you want.

Thanks -- your help is welcome :)

Quoted 5 lines

What is the minimum kernel version you want to support:
- 2.0.0
- 2.2.0
- 2.4.0
- 2.4.4

Check out the CVS tree, using the cvsroot/password given at
http://www.linux-mtd.infradead.org/

Observe that it contains 2.5-specific code, but builds for the 2.4 kernel too because of compatmac.h. It may, in fact, not build against 2.5 de jour because I may be slightly behind in my merging of 2.5-specific changes, but it shouldn't be far behind.

1. Observe that in some cases, _all_ that was required was to include that file in order to make the code work in 2.4.

2. Observe that in other cases we need a little bit of #ifdef to make it work, but that it's not _too_ ugly.

3. Observe that in further cases the ifdefs are getting _really_ ugly.

4. Observe that occasionally the ifdefs have got so ugly that we've split a driver into separate files for different versions of the kernel. Note the extra maintenance burden of having two separate copies of essentially the same driver.

The most helpful thing you can do is find drivers in state (3) and convert them to state (4). But please _do_ build and test against both 2.4 and 2.5 when doing so, and it's probably best to ask before spending your time on doing them -- the block device drivers are fine because they don't get much attention, so the extra cost of maintaining two versions instead of one is negligible. If, on the other hand, you suggest splitting fs/jffs2/dir.c into two separate files; one for <=2.4 and one for >=2.5, I'll ignore you :)

Quoted 2 lines

I haven't checked older kernels but at least kernel 2.2.20 includes all header files I've added (init.h, sched.h, vmalloc.h).

Sorry, I meant uClinux 2.0 -- as Greg pointed out, there was no uClinux 2.2. But to be honest I'm not _really_ bothered about anything earlier than about 2.4.14.

Signature · 1 line
dwmw2