Merge by hand (conflicts in sd.c)
[pandora-kernel.git] / drivers / scsi / aic7xxx / aic7xxx_osm.c
index 5417388..c932b3b 100644 (file)
 
 static struct scsi_transport_template *ahc_linux_transport_template = NULL;
 
-/*
- * Include aiclib.c as part of our
- * "module dependencies are hard" work around.
- */
-#include "aiclib.c"
-
 #include <linux/init.h>                /* __setup */
 #include <linux/mm.h>          /* For fetching system memory size */
 #include <linux/blkdev.h>              /* For block_size() */
@@ -391,7 +385,6 @@ static int ahc_linux_run_command(struct ahc_softc*,
                                 struct ahc_linux_device *,
                                 struct scsi_cmnd *);
 static void ahc_linux_setup_tag_info_global(char *p);
-static aic_option_callback_t ahc_linux_setup_tag_info;
 static int  aic7xxx_setup(char *s);
 
 static int ahc_linux_unit;
@@ -920,6 +913,86 @@ ahc_linux_setup_tag_info(u_long arg, int instance, int targ, int32_t value)
        }
 }
 
+static char *
+ahc_parse_brace_option(char *opt_name, char *opt_arg, char *end, int depth,
+                      void (*callback)(u_long, int, int, int32_t),
+                      u_long callback_arg)
+{
+       char    *tok_end;
+       char    *tok_end2;
+       int      i;
+       int      instance;
+       int      targ;
+       int      done;
+       char     tok_list[] = {'.', ',', '{', '}', '\0'};
+
+       /* All options use a ':' name/arg separator */
+       if (*opt_arg != ':')
+               return (opt_arg);
+       opt_arg++;
+       instance = -1;
+       targ = -1;
+       done = FALSE;
+       /*
+        * Restore separator that may be in
+        * the middle of our option argument.
+        */
+       tok_end = strchr(opt_arg, '\0');
+       if (tok_end < end)
+               *tok_end = ',';
+       while (!done) {
+               switch (*opt_arg) {
+               case '{':
+                       if (instance == -1) {
+                               instance = 0;
+                       } else {
+                               if (depth > 1) {
+                                       if (targ == -1)
+                                               targ = 0;
+                               } else {
+                                       printf("Malformed Option %s\n",
+                                              opt_name);
+                                       done = TRUE;
+                               }
+                       }
+                       opt_arg++;
+                       break;
+               case '}':
+                       if (targ != -1)
+                               targ = -1;
+                       else if (instance != -1)
+                               instance = -1;
+                       opt_arg++;
+                       break;
+               case ',':
+               case '.':
+                       if (instance == -1)
+                               done = TRUE;
+                       else if (targ >= 0)
+                               targ++;
+                       else if (instance >= 0)
+                               instance++;
+                       opt_arg++;
+                       break;
+               case '\0':
+                       done = TRUE;
+                       break;
+               default:
+                       tok_end = end;
+                       for (i = 0; tok_list[i]; i++) {
+                               tok_end2 = strchr(opt_arg, tok_list[i]);
+                               if ((tok_end2) && (tok_end2 < tok_end))
+                                       tok_end = tok_end2;
+                       }
+                       callback(callback_arg, instance, targ,
+                                simple_strtol(opt_arg, NULL, 0));
+                       opt_arg = tok_end;
+                       break;
+               }
+       }
+       return (opt_arg);
+}
+
 /*
  * Handle Linux boot parameters. This routine allows for assigning a value
  * to a parameter with a ':' between the parameter and the value.
@@ -974,7 +1047,7 @@ aic7xxx_setup(char *s)
                if (strncmp(p, "global_tag_depth", n) == 0) {
                        ahc_linux_setup_tag_info_global(p + n);
                } else if (strncmp(p, "tag_info", n) == 0) {
-                       s = aic_parse_brace_option("tag_info", p + n, end,
+                       s = ahc_parse_brace_option("tag_info", p + n, end,
                            2, ahc_linux_setup_tag_info, 0);
                } else if (p[n] == ':') {
                        *(options[i].flag) = simple_strtoul(p + n + 1, NULL, 0);