mtd/include/linux/mtd compatmac.h,1.48,1.49 mtd.h,1.42,1.43
David Woodhouse
dwmw2 at infradead.org
Wed May 14 18:27:00 EDT 2003
Update of /home/cvs/mtd/include/linux/mtd
In directory phoenix.infradead.org:/tmp/cvs-serv14262/include/linux/mtd
Modified Files:
compatmac.h mtd.h
Log Message:
fix races in get_mtd_device etc, use set_module_owner everywhere
Index: compatmac.h
===================================================================
RCS file: /home/cvs/mtd/include/linux/mtd/compatmac.h,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- compatmac.h 9 May 2003 22:54:28 -0000 1.48
+++ compatmac.h 14 May 2003 22:26:26 -0000 1.49
@@ -578,4 +578,11 @@
#define generic_file_readonly_mmap generic_file_mmap
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,60)
+#define try_module_get(m) ({ __MOD_INC_USE_COUNT(m), 1; })
+#define __module_get(m) ({ __MOD_INC_USE_COUNT(m), 1; })
+#define module_put(m) do { __MOD_DEC_USE_COUNT(m); } while(0)
+#define set_module_owner(x) do { x->owner = THIS_MODULE; } while(0)
+#endif
+
#endif /* __LINUX_MTD_COMPATMAC_H__ */
Index: mtd.h
===================================================================
RCS file: /home/cvs/mtd/include/linux/mtd/mtd.h,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- mtd.h 27 Feb 2003 16:03:58 -0000 1.42
+++ mtd.h 14 May 2003 22:26:26 -0000 1.43
@@ -171,7 +171,6 @@
/* This really shouldn't be here. It can go away in 2.5 */
u_int32_t bank_size;
- struct module *module;
int (*erase) (struct mtd_info *mtd, struct erase_info *instr);
/* This stuff for eXecute-In-Place */
@@ -226,6 +225,9 @@
void (*resume) (struct mtd_info *mtd);
void *priv;
+
+ struct module *owner;
+ int usecount;
};
@@ -234,31 +236,19 @@
extern int add_mtd_device(struct mtd_info *mtd);
extern int del_mtd_device (struct mtd_info *mtd);
-extern struct mtd_info *__get_mtd_device(struct mtd_info *mtd, int num);
+#define get_mtd_device(mtd, num) ___get_mtd_device(mtd, num, 1)
+#undef __get_mtd_device
+#define __get_mtd_device(mtd, num) ___get_mtd_device(mtd, num, 0)
+
+extern struct mtd_info *___get_mtd_device(struct mtd_info *mtd, int num, int count);
-static inline struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num)
-{
- struct mtd_info *ret;
-
- ret = __get_mtd_device(mtd, num);
-
- if (ret && ret->module && !try_inc_mod_count(ret->module))
- return NULL;
-
- return ret;
-}
-
-static inline void put_mtd_device(struct mtd_info *mtd)
-{
- if (mtd->module)
- __MOD_DEC_USE_COUNT(mtd->module);
-}
+extern void put_mtd_device(struct mtd_info *mtd);
struct mtd_notifier {
void (*add)(struct mtd_info *mtd);
void (*remove)(struct mtd_info *mtd);
- struct mtd_notifier *next;
+ struct list_head list;
};
@@ -271,7 +261,6 @@
int default_mtd_readv(struct mtd_info *mtd, struct iovec *vecs,
unsigned long count, loff_t from, size_t *retlen);
-#ifndef MTDC
#define MTD_ERASE(mtd, args...) (*(mtd->erase))(mtd, args)
#define MTD_POINT(mtd, a,b,c,d) (*(mtd->point))(mtd, a,b,c, (u_char **)(d))
#define MTD_UNPOINT(mtd, arg) (*(mtd->unpoint))(mtd, (u_char *)arg)
@@ -284,7 +273,6 @@
#define MTD_READOOB(mtd, args...) (*(mtd->read_oob))(mtd, args)
#define MTD_WRITEOOB(mtd, args...) (*(mtd->write_oob))(mtd, args)
#define MTD_SYNC(mtd) do { if (mtd->sync) (*(mtd->sync))(mtd); } while (0)
-#endif /* MTDC */
/*
* Debugging macro and defines
@@ -301,7 +289,8 @@
printk(KERN_INFO args); \
} while(0)
#else /* CONFIG_MTD_DEBUG */
-#define DEBUG(n, args...)
+#define DEBUG(n, args...) do { } while(0)
+
#endif /* CONFIG_MTD_DEBUG */
#endif /* __KERNEL__ */
More information about the linux-mtd-cvs
mailing list