- Update to 3.4-rc3.
[linux-flexiantxendom0-3.2.10.git] / scripts / mod / modpost.c
index c4e7d15..566fbe4 100644 (file)
@@ -1682,6 +1682,48 @@ static void check_sec_ref(struct module *mod, const char *modname,
        }
 }
 
+void *supported_file;
+unsigned long supported_size;
+
+static const char *supported(struct module *mod)
+{
+       unsigned long pos = 0;
+       char *line;
+
+       /* In a first shot, do a simple linear scan. */
+       while ((line = get_next_line(&pos, supported_file,
+                                    supported_size))) {
+               const char *basename, *how = "yes";
+               char *l = line;
+
+               /* optional type-of-support flag */
+               for (l = line; *l != '\0'; l++) {
+                       if (*l == ' ' || *l == '\t') {
+                               *l = '\0';
+                               how = l + 1;
+                               break;
+                       }
+               }
+
+               /* skip directory components */
+               if ((l = strrchr(line, '/')))
+                       line = l + 1;
+               /* strip .ko extension */
+               l = line + strlen(line);
+               if (l - line > 3 && !strcmp(l-3, ".ko"))
+                       *(l-3) = '\0';
+
+               /* skip directory components */
+               if ((basename = strrchr(mod->name, '/')))
+                       basename++;
+               else
+                       basename = mod->name;
+               if (!strcmp(basename, line))
+                       return how;
+       }
+       return NULL;
+}
+
 static void read_symbols(char *modname)
 {
        const char *symname;
@@ -1875,6 +1917,13 @@ static void add_staging_flag(struct buffer *b, const char *name)
                buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n");
 }
 
+static void add_supported_flag(struct buffer *b, struct module *mod)
+{
+       const char *how = supported(mod);
+       if (how)
+               buf_printf(b, "\nMODULE_INFO(supported, \"%s\");\n", how);
+}
+
 /**
  * Record CRCs for unresolved symbols
  **/
@@ -2015,6 +2064,13 @@ static void write_if_changed(struct buffer *b, const char *fname)
        fclose(file);
 }
 
+static void read_supported(const char *fname)
+{
+       supported_file = grab_file(fname, &supported_size);
+       if (!supported_file)
+               ; /* ignore error */
+}
+
 /* parse Module.symvers file. line format:
  * 0x12345678<tab>symbol<tab>module[[<tab>export]<tab>something]
  **/
@@ -2108,12 +2164,13 @@ int main(int argc, char **argv)
        struct buffer buf = { };
        char *kernel_read = NULL, *module_read = NULL;
        char *dump_write = NULL;
+       const char *supported = NULL;
        int opt;
        int err;
        struct ext_sym_list *extsym_iter;
        struct ext_sym_list *extsym_start = NULL;
 
-       while ((opt = getopt(argc, argv, "i:I:e:cmsSo:awM:K:")) != -1) {
+       while ((opt = getopt(argc, argv, "i:I:e:cmsSo:awM:K:N:")) != -1) {
                switch (opt) {
                case 'i':
                        kernel_read = optarg;
@@ -2151,11 +2208,16 @@ int main(int argc, char **argv)
                case 'w':
                        warn_unresolved = 1;
                        break;
+               case 'N':
+                       supported = optarg;
+                       break;
                default:
                        exit(1);
                }
        }
 
+       if (supported)
+               read_supported(supported);
        if (kernel_read)
                read_dump(kernel_read, 1);
        if (module_read)
@@ -2189,6 +2251,7 @@ int main(int argc, char **argv)
                add_header(&buf, mod);
                add_intree_flag(&buf, !external_module);
                add_staging_flag(&buf, mod->name);
+               add_supported_flag(&buf, mod);
                err |= add_versions(&buf, mod);
                add_depends(&buf, mod, modules);
                add_moddevtable(&buf, mod);