ftdi_eeprom: If we don't understand the argument, tell the user and abort
authorUwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
Wed, 31 Aug 2011 16:09:44 +0000 (18:09 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Fri, 2 Sep 2011 12:01:16 +0000 (14:01 +0200)
ftdi_eeprom/main.c

index 950bad7..a765d8c 100644 (file)
@@ -170,11 +170,15 @@ int main(int argc, char *argv[])
     {
         if (strcmp(argv[1], "--read-eeprom") == 0)
             _read = 1;
-        if (strcmp(argv[1], "--erase-eeprom") == 0)
+        else if (strcmp(argv[1], "--erase-eeprom") == 0)
             _erase = 1;
-        if (strcmp(argv[1], "--flash-eeprom") == 0)
+        else if (strcmp(argv[1], "--flash-eeprom") == 0)
             _flash = 1;
-
+        else
+        {
+            printf ("Can't open configuration file\n");
+            exit (-1);
+        }
         argc_filename = 2;
     }
     else
@@ -213,9 +217,6 @@ int main(int argc, char *argv[])
         if (i == 0)
         {
             printf("FTDI read eeprom: %d\n", ftdi_read_eeprom(ftdi));
-            eeprom_get_value(ftdi, CHIP_SIZE, &my_eeprom_size);
-            // TODO: Do we know the eeprom size already?
-            printf("EEPROM size: %d\n", my_eeprom_size);
         }
         else
         {
@@ -231,6 +232,9 @@ int main(int argc, char *argv[])
                 exit (-1);
             }
         }
+        eeprom_get_value(ftdi, CHIP_SIZE, &my_eeprom_size);
+        // TODO: Do we know the eeprom size already?
+        printf("EEPROM size: %d\n", my_eeprom_size);
     }
 
     if (_read > 0)