Skip to contentSkip to conversation

convert mtd/devices/doc* to symbol_put functions

PATCH In review Eric Sesterhenn 2 participants 3 messages Mar 23, 2006 – Apr 4, 2006

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

PATCH 1/1 convert mtd/devices/doc* to symbol_put functions

hi,

this is an attemt at converting the doc mtd drivers from inter_module_* functions to symbol_*
Compile tested with allyes and allmodconfig. Please comment, even if it looks halfways sane, so i know i can start working on mtd/chips/cfi* which is the last module using this stuff in the kernel.

drivers/mtd/devices/doc2000.c +5 -6
diff -ruN linux-2.6.16-git6/drivers/mtd/devices/doc2000.c linux-2.6.16-git6.new/drivers/mtd/devices/doc2000.c
@@ -519,11 +519,11 @@
 static const char im_name[] = "DoC2k_init";
 
 /* This routine is made available to other mtd code via
- * inter_module_register.  It must only be accessed through
- * inter_module_get which will bump the use count of this module.  The
+ * EXPORT_SYMBOL.  It must only be accessed through
+ * symbol_get which will bump the use count of this module.  The
  * addresses passed back in mtd are valid as long as the use count of
- * this module is non-zero, i.e. between inter_module_get and
- * inter_module_put.  Keith Owens <[email protected]> 29 Oct 2000.
+ * this module is non-zero, i.e. between symbol_get and
+ * symbol_put.  Keith Owens <[email protected]> 29 Oct 2000.
  */
 static void DoC2k_init(struct mtd_info *mtd)
 {
@@ -622,6 +622,7 @@
 		return;
 	}
 }
+EXPORT_SYMBOL(DoC2k_init);
 
 static int doc_read(struct mtd_info *mtd, loff_t from, size_t len,
 		    size_t * retlen, u_char * buf)
@@ -1278,7 +1279,6 @@
 
 static int __init init_doc2000(void)
 {
-       inter_module_register(im_name, THIS_MODULE, &DoC2k_init);
        return 0;
 }
 
@@ -1297,7 +1297,6 @@
 		kfree(this->chips);
 		kfree(mtd);
 	}
-	inter_module_unregister(im_name);
 }
 
 module_exit(cleanup_doc2000);

Files linux-2.6.16-git6/drivers/mtd/devices/.doc2000.c.swp and linux-2.6.16-git6.new/drivers/mtd/devices/.doc2000.c.swp differ

drivers/mtd/devices/doc2001.c +5 -6
diff -ruN linux-2.6.16-git6/drivers/mtd/devices/doc2001.c linux-2.6.16-git6.new/drivers/mtd/devices/doc2001.c
@@ -327,11 +327,11 @@
 static const char im_name[] = "DoCMil_init";
 
 /* This routine is made available to other mtd code via
- * inter_module_register.  It must only be accessed through
- * inter_module_get which will bump the use count of this module.  The
+ * EXPORT_SYMBOL.  It must only be accessed through
+ * symbol_get which will bump the use count of this module.  The
  * addresses passed back in mtd are valid as long as the use count of
- * this module is non-zero, i.e. between inter_module_get and
- * inter_module_put.  Keith Owens <[email protected]> 29 Oct 2000.
+ * this module is non-zero, i.e. between symbol_get and
+ * symbol_put.  Keith Owens <[email protected]> 29 Oct 2000.
  */
 static void DoCMil_init(struct mtd_info *mtd)
 {
@@ -401,6 +401,7 @@
 		return;
 	}
 }
+EXPORT_SYMBOL(DoCMil_init);
 
 static int doc_read (struct mtd_info *mtd, loff_t from, size_t len,
 		     size_t *retlen, u_char *buf)
@@ -858,7 +859,6 @@
 
 static int __init init_doc2001(void)
 {
-	inter_module_register(im_name, THIS_MODULE, &DoCMil_init);
 	return 0;
 }
 
@@ -877,7 +877,6 @@
 		kfree(this->chips);
 		kfree(mtd);
 	}
-	inter_module_unregister(im_name);
 }
 
 module_exit(cleanup_doc2001);
drivers/mtd/devices/doc2001plus.c +5 -6
diff -ruN linux-2.6.16-git6/drivers/mtd/devices/doc2001plus.c linux-2.6.16-git6.new/drivers/mtd/devices/doc2001plus.c
@@ -450,11 +450,11 @@
 static const char im_name[] = "DoCMilPlus_init";
 
 /* This routine is made available to other mtd code via
- * inter_module_register.  It must only be accessed through
- * inter_module_get which will bump the use count of this module.  The
+ * EXPORT_SYMBOL.  It must only be accessed through
+ * symbol_get which will bump the use count of this module.  The
  * addresses passed back in mtd are valid as long as the use count of
- * this module is non-zero, i.e. between inter_module_get and
- * inter_module_put.  Keith Owens <[email protected]> 29 Oct 2000.
+ * this module is non-zero, i.e. between symbol_get and
+ * symbol_put.  Keith Owens <[email protected]> 29 Oct 2000.
  */
 static void DoCMilPlus_init(struct mtd_info *mtd)
 {
@@ -524,6 +524,7 @@
 		return;
 	}
 }
+EXPORT_SYMBOL(DoCMilPlus_init);
 
 #if 0
 static int doc_dumpblk(struct mtd_info *mtd, loff_t from)
@@ -1124,7 +1125,6 @@
 
 static int __init init_doc2001plus(void)
 {
-	inter_module_register(im_name, THIS_MODULE, &DoCMilPlus_init);
 	return 0;
 }
 
@@ -1143,7 +1143,6 @@
 		kfree(this->chips);
 		kfree(mtd);
 	}
-	inter_module_unregister(im_name);
 }
 
 module_exit(cleanup_doc2001plus);
drivers/mtd/devices/docprobe.c +9 -4
diff -ruN linux-2.6.16-git6/drivers/mtd/devices/docprobe.c linux-2.6.16-git6.new/drivers/mtd/devices/docprobe.c
@@ -307,14 +307,19 @@
 			break;
 		}
 
-		if (im_funcname)
-			initroutine = inter_module_get_request(im_funcname, im_modname);
-
+		if (im_funcname) {
+			if (!request_module("%s", im_modname))
+				goto fail;
+			
+			initroutine = symbol_get(im_funcname);
+		}
+		
 		if (initroutine) {
 			(*initroutine)(mtd);
-			inter_module_put(im_funcname);
+			symbol_put(im_funcname);
 			return;
 		}
+fail:
 		printk(KERN_NOTICE "Cannot find driver for DiskOnChip %s at 0x%lX\n", name, physadr);
 		kfree(mtd);
 	}

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors

#1 lore raw
Quoted 4 lines · Eric Sesterhenn

this is an attemt at converting the doc mtd drivers from inter_module_* functions to symbol_*
Compile tested with allyes and allmodconfig. Please comment, even if it looks halfways sane,

Exporting static functions is something interesting.

Quoted 10 lines

so i know
i can start working on mtd/chips/cfi* which is the last module using this stuff in the kernel.

drivers/mtd/devices/doc2000.c +0 -0
 
 static void DoC2k_init(struct mtd_info *mtd)
 {

drivers/mtd/devices/doc2000.c line 625

Quoted 4 lines
drivers/mtd/devices/doc2000.c +1 -0
@@ -622,6 +622,7 @@
 		return;
 	}
 }
+EXPORT_SYMBOL(DoC2k_init);

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors

#2 lore raw
In reply to Eric Sesterhenn
Quoted 7 lines · Alexey Dobriyan
Quoted 4 lines · Eric Sesterhenn

this is an attemt at converting the doc mtd drivers from inter_module_* functions to symbol_*
Compile tested with allyes and allmodconfig. Please comment, even if it looks halfways sane,

Exporting static functions is something interesting.

Second attempt to convert doc* mtd drivers to the symbol_* api. compile tested with allyes and allmod config on i386

drivers/mtd/devices/doc2000.c +6 -7
diff -up linux-2.6.17-rc1.orig/drivers/mtd/devices/doc2000.c linux-2.6.17-rc1/drivers/mtd/devices/doc2000.c
@@ -520,13 +520,13 @@ static int DoC2k_is_alias(struct DiskOnC
 static const char im_name[] = "DoC2k_init";
 
 /* This routine is made available to other mtd code via
- * inter_module_register.  It must only be accessed through
- * inter_module_get which will bump the use count of this module.  The
+ * EXPORT_SYMBOL.  It must only be accessed through
+ * symbol_get which will bump the use count of this module.  The
  * addresses passed back in mtd are valid as long as the use count of
- * this module is non-zero, i.e. between inter_module_get and
- * inter_module_put.  Keith Owens <[email protected]> 29 Oct 2000.
+ * this module is non-zero, i.e. between symbol_get and
+ * symbol_put.  Keith Owens <[email protected]> 29 Oct 2000.
  */
-static void DoC2k_init(struct mtd_info *mtd)
+void DoC2k_init(struct mtd_info *mtd)
 {
 	struct DiskOnChip *this = mtd->priv;
 	struct DiskOnChip *old = NULL;
@@ -623,6 +623,7 @@ static void DoC2k_init(struct mtd_info *
 		return;
 	}
 }
+EXPORT_SYMBOL(DoC2k_init);
 
 static int doc_read(struct mtd_info *mtd, loff_t from, size_t len,
 		    size_t * retlen, u_char * buf)
@@ -1279,7 +1280,6 @@ static int doc_erase(struct mtd_info *mt
 
 static int __init init_doc2000(void)
 {
-       inter_module_register(im_name, THIS_MODULE, &DoC2k_init);
        return 0;
 }
 
@@ -1298,7 +1298,6 @@ static void __exit cleanup_doc2000(void)
 		kfree(this->chips);
 		kfree(mtd);
 	}
-	inter_module_unregister(im_name);
 }
 
 module_exit(cleanup_doc2000);

Only in linux-2.6.17-rc1/drivers/mtd/devices/: doc2000.c.orig

drivers/mtd/devices/doc2001.c +6 -7
diff -up linux-2.6.17-rc1.orig/drivers/mtd/devices/doc2001.c linux-2.6.17-rc1/drivers/mtd/devices/doc2001.c
@@ -327,13 +327,13 @@ static int DoCMil_is_alias(struct DiskOn
 static const char im_name[] = "DoCMil_init";
 
 /* This routine is made available to other mtd code via
- * inter_module_register.  It must only be accessed through
- * inter_module_get which will bump the use count of this module.  The
+ * EXPORT_SYMBOL.  It must only be accessed through
+ * symbol_get which will bump the use count of this module.  The
  * addresses passed back in mtd are valid as long as the use count of
- * this module is non-zero, i.e. between inter_module_get and
- * inter_module_put.  Keith Owens <[email protected]> 29 Oct 2000.
+ * this module is non-zero, i.e. between symbol_get and
+ * symbol_put.  Keith Owens <[email protected]> 29 Oct 2000.
  */
-static void DoCMil_init(struct mtd_info *mtd)
+void DoCMil_init(struct mtd_info *mtd)
 {
 	struct DiskOnChip *this = mtd->priv;
 	struct DiskOnChip *old = NULL;
@@ -401,6 +401,7 @@ static void DoCMil_init(struct mtd_info 
 		return;
 	}
 }
+EXPORT_SYMBOL(DoCMil_init);
 
 static int doc_read (struct mtd_info *mtd, loff_t from, size_t len,
 		     size_t *retlen, u_char *buf)
@@ -858,7 +859,6 @@ int doc_erase (struct mtd_info *mtd, str
 
 static int __init init_doc2001(void)
 {
-	inter_module_register(im_name, THIS_MODULE, &DoCMil_init);
 	return 0;
 }
 
@@ -877,7 +877,6 @@ static void __exit cleanup_doc2001(void)
 		kfree(this->chips);
 		kfree(mtd);
 	}
-	inter_module_unregister(im_name);
 }
 
 module_exit(cleanup_doc2001);
drivers/mtd/devices/doc2001plus.c +6 -7
diff -up linux-2.6.17-rc1.orig/drivers/mtd/devices/doc2001plus.c linux-2.6.17-rc1/drivers/mtd/devices/doc2001plus.c
@@ -450,13 +450,13 @@ static int DoCMilPlus_is_alias(struct Di
 static const char im_name[] = "DoCMilPlus_init";
 
 /* This routine is made available to other mtd code via
- * inter_module_register.  It must only be accessed through
- * inter_module_get which will bump the use count of this module.  The
+ * EXPORT_SYMBOL.  It must only be accessed through
+ * symbol_get which will bump the use count of this module.  The
  * addresses passed back in mtd are valid as long as the use count of
- * this module is non-zero, i.e. between inter_module_get and
- * inter_module_put.  Keith Owens <[email protected]> 29 Oct 2000.
+ * this module is non-zero, i.e. between symbol_get and
+ * symbol_put.  Keith Owens <[email protected]> 29 Oct 2000.
  */
-static void DoCMilPlus_init(struct mtd_info *mtd)
+void DoCMilPlus_init(struct mtd_info *mtd)
 {
 	struct DiskOnChip *this = mtd->priv;
 	struct DiskOnChip *old = NULL;
@@ -524,6 +524,7 @@ static void DoCMilPlus_init(struct mtd_i
 		return;
 	}
 }
+EXPORT_SYMBOL(DoCMilPlus_init);
 
 #if 0
 static int doc_dumpblk(struct mtd_info *mtd, loff_t from)
@@ -1124,7 +1125,6 @@ int doc_erase(struct mtd_info *mtd, stru
 
 static int __init init_doc2001plus(void)
 {
-	inter_module_register(im_name, THIS_MODULE, &DoCMilPlus_init);
 	return 0;
 }
 
@@ -1143,7 +1143,6 @@ static void __exit cleanup_doc2001plus(v
 		kfree(this->chips);
 		kfree(mtd);
 	}
-	inter_module_unregister(im_name);
 }
 
 module_exit(cleanup_doc2001plus);
drivers/mtd/devices/docprobe.c +9 -4
diff -up linux-2.6.17-rc1.orig/drivers/mtd/devices/docprobe.c linux-2.6.17-rc1/drivers/mtd/devices/docprobe.c
@@ -307,14 +307,19 @@ static void __init DoC_Probe(unsigned lo
 			break;
 		}
 
-		if (im_funcname)
-			initroutine = inter_module_get_request(im_funcname, im_modname);
-
+		if (im_funcname) {
+			if (!request_module("%s", im_modname))
+				goto fail;
+			
+			initroutine = symbol_get(im_funcname);
+		}
+		
 		if (initroutine) {
 			(*initroutine)(mtd);
-			inter_module_put(im_funcname);
+			symbol_put(im_funcname);
 			return;
 		}
+fail:
 		printk(KERN_NOTICE "Cannot find driver for DiskOnChip %s at 0x%lX\n", name, physadr);
 		kfree(mtd);
 	}

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors