summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2011-12-25 09:07:59 +0000
committerStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2011-12-25 09:07:59 +0000
commit104b0d9f1e1e41bda61f82a688971f3a31074d73 (patch)
tree263131cbe4a80eb0413a119a30760ee2146e1772
parentb3850964f6a87f107e7eaae16d75299f32cc6e76 (diff)
downloadast2050-flashrom-104b0d9f1e1e41bda61f82a688971f3a31074d73.zip
ast2050-flashrom-104b0d9f1e1e41bda61f82a688971f3a31074d73.tar.gz
layout: change return type and name of find_next_included_romentry
- rename from find_next_included_romentry to get_next_included_romentry - return a pointer to a rom_entry instead of just its index. this relieves the (single existing) caller from directly accessing the data structure holding the entries hence improving segregation and readability. Corresponding to flashrom svn r1481. Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
-rw-r--r--layout.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/layout.c b/layout.c
index 530ebd5..aef520c 100644
--- a/layout.c
+++ b/layout.c
@@ -215,26 +215,28 @@ int find_romentry(char *name)
return -1;
}
-int find_next_included_romentry(unsigned int start)
+romlayout_t *get_next_included_romentry(unsigned int start)
{
int i;
unsigned int best_start = UINT_MAX;
- int best_entry = -1;
+ romlayout_t *best_entry = NULL;
+ romlayout_t *cur;
/* First come, first serve for overlapping regions. */
for (i = 0; i < romimages; i++) {
- if (!rom_entries[i].included)
+ cur = &rom_entries[i];
+ if (!cur->included)
continue;
/* Already past the current entry? */
- if (start > rom_entries[i].end)
+ if (start > cur->end)
continue;
/* Inside the current entry? */
- if (start >= rom_entries[i].start)
- return i;
+ if (start >= cur->start)
+ return cur;
/* Entry begins after start. */
- if (best_start > rom_entries[i].start) {
- best_start = rom_entries[i].start;
- best_entry = i;
+ if (best_start > cur->start) {
+ best_start = cur->start;
+ best_entry = cur;
}
}
return best_entry;
@@ -243,7 +245,7 @@ int find_next_included_romentry(unsigned int start)
int handle_romentries(struct flashctx *flash, uint8_t *oldcontents, uint8_t *newcontents)
{
unsigned int start = 0;
- int entry;
+ romlayout_t *entry;
unsigned int size = flash->total_size * 1024;
/* If no layout file was specified or the layout file was empty, assume
@@ -255,22 +257,21 @@ int handle_romentries(struct flashctx *flash, uint8_t *oldcontents, uint8_t *new
* The union of all included romentries is used from the new image.
*/
while (start < size) {
- entry = find_next_included_romentry(start);
+ entry = get_next_included_romentry(start);
/* No more romentries for remaining region? */
- if (entry < 0) {
+ if (!entry) {
memcpy(newcontents + start, oldcontents + start,
size - start);
break;
}
- if (rom_entries[entry].start > start)
+ if (entry->start > start)
memcpy(newcontents + start, oldcontents + start,
- rom_entries[entry].start - start);
+ entry->start - start);
/* Skip to location after current romentry. */
- start = rom_entries[entry].end + 1;
+ start = entry->end + 1;
/* Catch overflow. */
if (!start)
break;
}
-
return 0;
}
OpenPOWER on IntegriCloud