]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - common/bootstage.c
bootstage: Drop unused options
[people/ms/u-boot.git] / common / bootstage.c
index 32f4e8b7060d12b7b5916a8ef331d5350b7f3faf..efc99fc681089a120d4278a66c7f6a393ac81a4d 100644 (file)
@@ -205,7 +205,7 @@ uint32_t bootstage_accum(enum bootstage_id id)
  * @return pointer to name, either from the record or pointing to buf.
  */
 static const char *get_record_name(char *buf, int len,
-                                  struct bootstage_record *rec)
+                                  const struct bootstage_record *rec)
 {
        if (rec->name)
                return rec->name;
@@ -264,7 +264,7 @@ static int add_bootstages_devicetree(struct fdt_header *blob)
         */
        bootstage = fdt_add_subnode(blob, 0, "bootstage");
        if (bootstage < 0)
-               return -1;
+               return -EINVAL;
 
        /*
         * Insert the timings to the device tree in the reverse order so
@@ -284,13 +284,13 @@ static int add_bootstages_devicetree(struct fdt_header *blob)
                /* add properties to the node. */
                if (fdt_setprop_string(blob, node, "name",
                                       get_record_name(buf, sizeof(buf), rec)))
-                       return -1;
+                       return -EINVAL;
 
                /* Check if this is a 'mark' or 'accum' record */
                if (fdt_setprop_cell(blob, node,
                                rec->start_us ? "accum" : "mark",
                                rec->time_us))
-                       return -1;
+                       return -EINVAL;
        }
 
        return 0;
@@ -361,9 +361,9 @@ static void append_data(char **ptrp, char *end, const void *data, int size)
 
 int bootstage_stash(void *base, int size)
 {
-       struct bootstage_data *data = gd->bootstage;
+       const struct bootstage_data *data = gd->bootstage;
        struct bootstage_hdr *hdr = (struct bootstage_hdr *)base;
-       struct bootstage_record *rec;
+       const struct bootstage_record *rec;
        char buf[20];
        char *ptr = base, *end = ptr + size;
        uint32_t count;
@@ -371,7 +371,7 @@ int bootstage_stash(void *base, int size)
 
        if (hdr + 1 > (struct bootstage_hdr *)end) {
                debug("%s: Not enough space for bootstage hdr\n", __func__);
-               return -1;
+               return -ENOSPC;
        }
 
        /* Write an arbitrary version number */
@@ -404,7 +404,7 @@ int bootstage_stash(void *base, int size)
        /* Check for buffer overflow */
        if (ptr > end) {
                debug("%s: Not enough space for bootstage stash\n", __func__);
-               return -1;
+               return -ENOSPC;
        }
 
        /* Update total data size */
@@ -414,12 +414,12 @@ int bootstage_stash(void *base, int size)
        return 0;
 }
 
-int bootstage_unstash(void *base, int size)
+int bootstage_unstash(const void *base, int size)
 {
+       const struct bootstage_hdr *hdr = (struct bootstage_hdr *)base;
        struct bootstage_data *data = gd->bootstage;
-       struct bootstage_hdr *hdr = (struct bootstage_hdr *)base;
+       const char *ptr = base, *end = ptr + size;
        struct bootstage_record *rec;
-       char *ptr = base, *end = ptr + size;
        uint rec_size;
        int i;
 
@@ -428,37 +428,37 @@ int bootstage_unstash(void *base, int size)
 
        if (hdr + 1 > (struct bootstage_hdr *)end) {
                debug("%s: Not enough space for bootstage hdr\n", __func__);
-               return -1;
+               return -EPERM;
        }
 
        if (hdr->magic != BOOTSTAGE_MAGIC) {
                debug("%s: Invalid bootstage magic\n", __func__);
-               return -1;
+               return -ENOENT;
        }
 
        if (ptr + hdr->size > end) {
                debug("%s: Bootstage data runs past buffer end\n", __func__);
-               return -1;
+               return -ENOSPC;
        }
 
        if (hdr->count * sizeof(*rec) > hdr->size) {
                debug("%s: Bootstage has %d records needing %lu bytes, but "
                        "only %d bytes is available\n", __func__, hdr->count,
                      (ulong)hdr->count * sizeof(*rec), hdr->size);
-               return -1;
+               return -ENOSPC;
        }
 
        if (hdr->version != BOOTSTAGE_VERSION) {
                debug("%s: Bootstage data version %#0x unrecognised\n",
                      __func__, hdr->version);
-               return -1;
+               return -EINVAL;
        }
 
        if (data->rec_count + hdr->count > RECORD_COUNT) {
                debug("%s: Bootstage has %d records, we have space for %d\n"
-                       "- please increase CONFIG_BOOTSTAGE_USER_COUNT\n",
+                       "- please increase CONFIG_BOOTSTAGE_RECORD_COUNT\n",
                      __func__, hdr->count, RECORD_COUNT - data->rec_count);
-               return -1;
+               return -ENOSPC;
        }
 
        ptr += sizeof(*hdr);
@@ -484,6 +484,11 @@ int bootstage_unstash(void *base, int size)
        return 0;
 }
 
+int bootstage_get_size(void)
+{
+       return sizeof(struct bootstage_data);
+}
+
 int bootstage_init(bool first)
 {
        struct bootstage_data *data;