]> git.sur5r.net Git - u-boot/blobdiff - cmd/cros_ec.c
fit: Verify all configuration signatures
[u-boot] / cmd / cros_ec.c
index abf11f07b277b16d0cd654e1fb0b7f77aeb13221..60c87838fdf86f1efc7639f10ac76a6e711fbc93 100644 (file)
@@ -1,10 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Chromium OS cros_ec driver
  *
  * Copyright (c) 2016 The Chromium OS Authors.
  * Copyright (c) 2016 National Instruments Corp
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
 /* Note: depends on enum ec_current_image */
 static const char * const ec_current_image_name[] = {"unknown", "RO", "RW"};
 
-DECLARE_GLOBAL_DATA_PTR;
+/**
+ * Decode a flash region parameter
+ *
+ * @param argc Number of params remaining
+ * @param argv List of remaining parameters
+ * @return flash region (EC_FLASH_REGION_...) or -1 on error
+ */
+static int cros_ec_decode_region(int argc, char * const argv[])
+{
+       if (argc > 0) {
+               if (0 == strcmp(*argv, "rw"))
+                       return EC_FLASH_REGION_RW;
+               else if (0 == strcmp(*argv, "ro"))
+                       return EC_FLASH_REGION_RO;
+
+               debug("%s: Invalid region '%s'\n", __func__, *argv);
+       } else {
+               debug("%s: Missing region parameter\n", __func__);
+       }
+
+       return -1;
+}
 
 /**
  * Perform a flash read or write command
@@ -87,7 +107,7 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                /* Remove any existing device */
                ret = uclass_find_device(UCLASS_CROS_EC, 0, &udev);
                if (!ret)
-                       device_remove(udev);
+                       device_remove(udev, DM_REMOVE_NORMAL);
                ret = uclass_get_device(UCLASS_CROS_EC, 0, &udev);
                if (ret) {
                        printf("Could not init cros_ec device (err %d)\n", ret);