Changeset 1474 for trunk/flashrom.c


Ignore:
Timestamp:
Dec 18, 2011, 4:01:24 PM (3 years ago)
Author:
hailfinger
Message:

Add struct flashctx * parameter to all functions accessing flash chips.

All programmer access function prototypes except init have been made
static and moved to the respective file.

A few internal functions in flash chip drivers had chipaddr parameters
which are no longer needed.

The lines touched by flashctx changes have been adjusted to 80 columns
except in header files.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@…>
Acked-by: Michael Karcher <flashrom@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/flashrom.c

    r1473 r1474  
    360360} 
    361361 
    362 void chip_writeb(uint8_t val, chipaddr addr) 
    363 { 
    364         par_programmer->chip_writeb(val, addr); 
    365 } 
    366  
    367 void chip_writew(uint16_t val, chipaddr addr) 
    368 { 
    369         par_programmer->chip_writew(val, addr); 
    370 } 
    371  
    372 void chip_writel(uint32_t val, chipaddr addr) 
    373 { 
    374         par_programmer->chip_writel(val, addr); 
    375 } 
    376  
    377 void chip_writen(uint8_t *buf, chipaddr addr, size_t len) 
    378 { 
    379         par_programmer->chip_writen(buf, addr, len); 
    380 } 
    381  
    382 uint8_t chip_readb(const chipaddr addr) 
    383 { 
    384         return par_programmer->chip_readb(addr); 
    385 } 
    386  
    387 uint16_t chip_readw(const chipaddr addr) 
    388 { 
    389         return par_programmer->chip_readw(addr); 
    390 } 
    391  
    392 uint32_t chip_readl(const chipaddr addr) 
    393 { 
    394         return par_programmer->chip_readl(addr); 
    395 } 
    396  
    397 void chip_readn(uint8_t *buf, chipaddr addr, size_t len) 
    398 { 
    399         par_programmer->chip_readn(buf, addr, len); 
     362void chip_writeb(const struct flashctx *flash, uint8_t val, chipaddr addr) 
     363{ 
     364        par_programmer->chip_writeb(flash, val, addr); 
     365} 
     366 
     367void chip_writew(const struct flashctx *flash, uint16_t val, chipaddr addr) 
     368{ 
     369        par_programmer->chip_writew(flash, val, addr); 
     370} 
     371 
     372void chip_writel(const struct flashctx *flash, uint32_t val, chipaddr addr) 
     373{ 
     374        par_programmer->chip_writel(flash, val, addr); 
     375} 
     376 
     377void chip_writen(const struct flashctx *flash, uint8_t *buf, chipaddr addr, 
     378                 size_t len) 
     379{ 
     380        par_programmer->chip_writen(flash, buf, addr, len); 
     381} 
     382 
     383uint8_t chip_readb(const struct flashctx *flash, const chipaddr addr) 
     384{ 
     385        return par_programmer->chip_readb(flash, addr); 
     386} 
     387 
     388uint16_t chip_readw(const struct flashctx *flash, const chipaddr addr) 
     389{ 
     390        return par_programmer->chip_readw(flash, addr); 
     391} 
     392 
     393uint32_t chip_readl(const struct flashctx *flash, const chipaddr addr) 
     394{ 
     395        return par_programmer->chip_readl(flash, addr); 
     396} 
     397 
     398void chip_readn(const struct flashctx *flash, uint8_t *buf, chipaddr addr, 
     399                size_t len) 
     400{ 
     401        par_programmer->chip_readn(flash, buf, addr, len); 
    400402} 
    401403 
     
    413415} 
    414416 
    415 int read_memmapped(struct flashctx *flash, uint8_t *buf, unsigned int start, int unsigned len) 
    416 { 
    417         chip_readn(buf, flash->virtual_memory + start, len); 
     417int read_memmapped(struct flashctx *flash, uint8_t *buf, unsigned int start, 
     418                   int unsigned len) 
     419{ 
     420        chip_readn(flash, buf, flash->virtual_memory + start, len); 
    418421 
    419422        return 0; 
     
    536539 
    537540/* start is an offset to the base address of the flash chip */ 
    538 int check_erased_range(struct flashctx *flash, unsigned int start, unsigned int len) 
     541int check_erased_range(struct flashctx *flash, unsigned int start, 
     542                       unsigned int len) 
    539543{ 
    540544        int ret; 
     
    559563 * @return      0 for success, -1 for failure 
    560564 */ 
    561 int verify_range(struct flashctx *flash, uint8_t *cmpbuf, unsigned int start, unsigned int len, 
    562                  const char *message) 
     565int verify_range(struct flashctx *flash, uint8_t *cmpbuf, unsigned int start, 
     566                 unsigned int len, const char *message) 
    563567{ 
    564568        unsigned int i; 
     
    15381542         * after the members copied from struct flashchip. 
    15391543         */ 
    1540         if (sizeof(struct flashchip) != offsetof(struct flashctx, virtual_memory)) { 
     1544        if (sizeof(struct flashchip) != 
     1545            offsetof(struct flashctx, virtual_memory)) { 
    15411546                msg_gerr("struct flashctx broken!\n"); 
    15421547                ret = 1; 
     
    16191624 * function signature. 
    16201625 */ 
    1621 int chip_safety_check(struct flashctx *flash, int force, int read_it, int write_it, int erase_it, int verify_it) 
     1626int chip_safety_check(struct flashctx *flash, int force, int read_it, 
     1627                      int write_it, int erase_it, int verify_it) 
    16221628{ 
    16231629        if (!programmer_may_write && (write_it || erase_it)) { 
     
    16801686 * Besides that, the function itself is a textbook example of abysmal code flow. 
    16811687 */ 
    1682 int doit(struct flashctx *flash, int force, const char *filename, int read_it, int write_it, int erase_it, int verify_it) 
     1688int doit(struct flashctx *flash, int force, const char *filename, int read_it, 
     1689         int write_it, int erase_it, int verify_it) 
    16831690{ 
    16841691        uint8_t *oldcontents; 
Note: See TracChangeset for help on using the changeset viewer.