ssb-sprom: Add warnings.
[b43-tools.git] / ssb_sprom / ssb_sprom.c
index facacab9f643f0ca9762908f79ce2f0f9610e9c4..10952775eec72e68028ebed4acd0c9e92efda88f 100644 (file)
@@ -2,7 +2,7 @@
 
   Broadcom Sonics Silicon Backplane bus SPROM data modification tool
 
-  Copyright (c) 2006-2007 Michael Buesch <mb@bu3sch.de>
+  Copyright (c) 2006-2008 Michael Buesch <mb@bu3sch.de>
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -293,10 +293,16 @@ static int modify_value(uint8_t *sprom,
                        sprom[SPROM_BOARDREV + 1] |= (1 << 5);
                break;
        case VALUE_ANTGA:
-               sprom[SPROM_ANTENNA_GAIN + 0] = (v & 0xFF);
+               if (sprom_rev != 4)
+                       sprom[SPROM_ANTENNA_GAIN + 1] = (v & 0xFF);
+               else
+                       sprom[SPROM4_ANTENNA_GAIN + 1] = (v & 0xFF);
                break;
        case VALUE_ANTGBG:
-               sprom[SPROM_ANTENNA_GAIN + 1] = (v & 0xFF);
+               if (sprom_rev != 4)
+                       sprom[SPROM_ANTENNA_GAIN] = (v & 0xFF);
+               else
+                       sprom[SPROM4_ANTENNA_GAIN] = (v & 0xFF);
                break;
        case VALUE_PA0B0:
                sprom[SPROM_PA0B0 + 0] = (v & 0x00FF);
@@ -574,7 +580,7 @@ static void display_value(const uint8_t *sprom,
        case VALUE_ANTGA:
                if (sprom_rev != 4) {
                        desc = "A PHY antenna gain";
-                       offset = SPROM_ANTENNA_GAIN + 1;
+                       offset = SPROM_ANTENNA_GAIN;
                } else {
                        desc = "Antenna 1 Gain";
                        offset = SPROM4_ANTENNA_GAIN;
@@ -912,7 +918,12 @@ static int open_outfile(int *fd)
 
 static void print_banner(int forceprint)
 {
-       const char *str = "Broadcom-SSB SPROM data modification tool version " VERSION "\n";
+       const char *str = "Broadcom-SSB SPROM data modification tool.\n"
+                         "\n"
+                         "Copyright (C) Michael Buesch\n"
+                         "Licensed under the GNU/GPL version 2 or later\n"
+                         "\n"
+                         "DO NOT USE THIS TOOL. YOU WILL BRICK YOUR DEVICE.\n";
        if (forceprint)
                prdata(str);
        else
@@ -1016,12 +1027,12 @@ static int do_cmp_arg(char **argv, int *pos,
        }
        if (strcmp(arg, template) == 0) {
                if (param) {
-                       /* Skip the parameter on the next iteration. */
-                       (*pos)++;
                        if (*param == 0) {
                                prerror("%s needs a parameter\n", arg);
                                return ARG_ERROR;
                        }
+                       /* Skip the parameter on the next iteration. */
+                       (*pos)++;
                }
                return ARG_MATCH;
        }
@@ -1511,7 +1522,8 @@ static int parse_args(int argc, char *argv[])
                        if (err)
                                goto error;
                } else {
-                       prerror("Unrecognized argument: %s\n", argv[i]);
+                       if (!parse_err)
+                               prerror("Unrecognized argument: %s\n", argv[i]);
                        goto out_usage;
                }
                if (parse_err)