On Wed, Feb 08, 2006 at 10:49:22AM -0800, Greg KH wrote:
> This patch adds the ability to mark symbols that will be changed in the
> future, so that non-GPL usage of them is flagged by the kernel and
> printed out to the system log.
> 
> Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>
The patch duplicate too much code to my taste at least.
May I suggest to consolidate a little in module.c before applying the
GPL_FUTURE stuff.

Have you considered: EXPORT_GPL_SOON()?

        Sam

See sample patch for potential consolidation:
[compiletime tested only...]

diff --git a/kernel/module.c b/kernel/module.c
index 618ed6e..e07a22e 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -135,6 +135,18 @@ extern const unsigned long __start___kcr
 #define symversion(base, idx) ((base) ? ((base) + (idx)) : NULL)
 #endif
 
+/* lookup symbol in given range of kernel_symbols */
+static int lookup_symbol(const char *name,
+                        const struct kernel_symbol *start,
+                        const struct kernel_symbol *stop)
+{
+       unsigned int i;
+       for (i = 0; start + i < stop; i++)
+               if (strcmp(start[i].name, name) == 0)
+                       return i;
+       return -1;
+}
+
 /* Find a symbol, return value, crc and module which owns it */
 static unsigned long __find_symbol(const char *name,
                                   struct module **owner,
@@ -142,39 +154,40 @@ static unsigned long __find_symbol(const
                                   int gplok)
 {
        struct module *mod;
-       unsigned int i;
+       int i;
 
        /* Core kernel first. */ 
        *owner = NULL;
-       for (i = 0; __start___ksymtab+i < __stop___ksymtab; i++) {
-               if (strcmp(__start___ksymtab[i].name, name) == 0) {
-                       *crc = symversion(__start___kcrctab, i);
-                       return __start___ksymtab[i].value;
-               }
+       i = lookup_symbol(name, __start___ksymtab, __stop___ksymtab);
+       if (i >= 0) {
+               *crc = symversion(__start___kcrctab, i);
+               return __start___ksymtab[i].value;
        }
        if (gplok) {
-               for (i = 0; __start___ksymtab_gpl+i<__stop___ksymtab_gpl; i++)
-                       if (strcmp(__start___ksymtab_gpl[i].name, name) == 0) {
-                               *crc = symversion(__start___kcrctab_gpl, i);
-                               return __start___ksymtab_gpl[i].value;
-                       }
+               i = lookup_symbol(name, __start___ksymtab_gpl,
+                                       __stop___ksymtab_gpl);
+               if (i >= 0) {
+                       *crc = symversion(__start___kcrctab_gpl, i);
+                       return __start___ksymtab_gpl[i].value;
+               }
        }
 
        /* Now try modules. */ 
        list_for_each_entry(mod, &modules, list) {
                *owner = mod;
-               for (i = 0; i < mod->num_syms; i++)
-                       if (strcmp(mod->syms[i].name, name) == 0) {
-                               *crc = symversion(mod->crcs, i);
-                               return mod->syms[i].value;
-                       }
+               i = lookup_symbol(name, mod->syms, mod->syms + mod->num_syms);
+               if (i >= 0) {
+                       *crc = symversion(mod->crcs, i);
+                       return mod->syms[i].value;
+               }
 
                if (gplok) {
-                       for (i = 0; i < mod->num_gpl_syms; i++) {
-                               if (strcmp(mod->gpl_syms[i].name, name) == 0) {
-                                       *crc = symversion(mod->gpl_crcs, i);
-                                       return mod->gpl_syms[i].value;
-                               }
+                       i = lookup_symbol(name, 
+                                         mod->gpl_syms,
+                                         mod->gpl_syms + mod->num_gpl_syms);
+                       if (i >= 0) {
+                               *crc = symversion(mod->gpl_crcs, i);
+                               return mod->gpl_syms[i].value;
                        }
                }
        }


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to