Changeset 1481


Ignore:
Timestamp:
12/25/11 10:07:59 (5 months ago)
Author:
stefanct
Message:

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.

Signed-off-by: Stefan Tauner <stefan.tauner@…>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/layout.c

    r1473 r1481  
    216216} 
    217217 
    218 int find_next_included_romentry(unsigned int start) 
     218romlayout_t *get_next_included_romentry(unsigned int start) 
    219219{ 
    220220        int i; 
    221221        unsigned int best_start = UINT_MAX; 
    222         int best_entry = -1; 
     222        romlayout_t *best_entry = NULL; 
     223        romlayout_t *cur; 
    223224 
    224225        /* First come, first serve for overlapping regions. */ 
    225226        for (i = 0; i < romimages; i++) { 
    226                 if (!rom_entries[i].included) 
     227                cur = &rom_entries[i]; 
     228                if (!cur->included) 
    227229                        continue; 
    228230                /* Already past the current entry? */ 
    229                 if (start > rom_entries[i].end) 
     231                if (start > cur->end) 
    230232                        continue; 
    231233                /* Inside the current entry? */ 
    232                 if (start >= rom_entries[i].start) 
    233                         return i; 
     234                if (start >= cur->start) 
     235                        return cur; 
    234236                /* Entry begins after start. */ 
    235                 if (best_start > rom_entries[i].start) { 
    236                         best_start = rom_entries[i].start; 
    237                         best_entry = i; 
     237                if (best_start > cur->start) { 
     238                        best_start = cur->start; 
     239                        best_entry = cur; 
    238240                } 
    239241        } 
     
    244246{ 
    245247        unsigned int start = 0; 
    246         int entry; 
     248        romlayout_t *entry; 
    247249        unsigned int size = flash->total_size * 1024; 
    248250 
     
    256258         */ 
    257259        while (start < size) { 
    258                 entry = find_next_included_romentry(start); 
     260                entry = get_next_included_romentry(start); 
    259261                /* No more romentries for remaining region? */ 
    260                 if (entry < 0) { 
     262                if (!entry) { 
    261263                        memcpy(newcontents + start, oldcontents + start, 
    262264                               size - start); 
    263265                        break; 
    264266                } 
    265                 if (rom_entries[entry].start > start) 
     267                if (entry->start > start) 
    266268                        memcpy(newcontents + start, oldcontents + start, 
    267                                rom_entries[entry].start - start); 
     269                               entry->start - start); 
    268270                /* Skip to location after current romentry. */ 
    269                 start = rom_entries[entry].end + 1; 
     271                start = entry->end + 1; 
    270272                /* Catch overflow. */ 
    271273                if (!start) 
    272274                        break; 
    273275        } 
    274                          
    275276        return 0; 
    276277} 
Note: See TracChangeset for help on using the changeset viewer.