Changeset 727 for trunk/spi.c


Ignore:
Timestamp:
Sep 18, 2009, 5:50:56 PM (5 years ago)
Author:
hailfinger
Message:

The current ICH SPI preop handling is a hack which spews lots of
warnings, but still yields correct results.
With the multicommand infrastructure I introduced in r645, it became
possible to integrate ICH SPI preopcodes cleanly into the flashrom
design.

The new code checks for every opcode in a multicommand array if it is a
preopcode. If yes, it checks if the next opcode is associated with that
preopcode and in that case it simply runs the opcode because the correct
preopcode will be run automatically before the opcode.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@…>
Acked-by: FENG Yu Ning <fengyuning1984@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/spi.c

    r724 r727  
    119119} 
    120120 
    121 int spi_send_multicommand(struct spi_command *spicommands) 
     121int spi_send_multicommand(struct spi_command *cmds) 
    122122{ 
    123123        if (!spi_programmer[spi_controller].multicommand) { 
     
    127127        } 
    128128 
    129         return spi_programmer[spi_controller].multicommand(spicommands); 
     129        return spi_programmer[spi_controller].multicommand(cmds); 
    130130} 
    131131 
     
    149149} 
    150150 
    151 int default_spi_send_multicommand(struct spi_command *spicommands) 
     151int default_spi_send_multicommand(struct spi_command *cmds) 
    152152{ 
    153153        int result = 0; 
    154         while ((spicommands->writecnt || spicommands->readcnt) && !result) { 
    155                 result = spi_send_command(spicommands->writecnt, spicommands->readcnt, 
    156                                           spicommands->writearr, spicommands->readarr); 
    157                 spicommands++; 
     154        for (; (cmds->writecnt || cmds->readcnt) && !result; cmds++) { 
     155                result = spi_send_command(cmds->writecnt, cmds->readcnt, 
     156                                          cmds->writearr, cmds->readarr); 
    158157        } 
    159158        return result; 
     
    495494{ 
    496495        int result; 
    497         struct spi_command spicommands[] = { 
     496        struct spi_command cmds[] = { 
    498497        { 
    499498                .writecnt       = JEDEC_WREN_OUTSIZE, 
     
    519518        } 
    520519         
    521         result = spi_send_multicommand(spicommands); 
     520        result = spi_send_multicommand(cmds); 
    522521        if (result) { 
    523522                fprintf(stderr, "%s failed during command execution\n", 
     
    541540{ 
    542541        int result; 
    543         struct spi_command spicommands[] = { 
     542        struct spi_command cmds[] = { 
    544543        { 
    545544                .writecnt       = JEDEC_WREN_OUTSIZE, 
     
    565564        } 
    566565 
    567         result = spi_send_multicommand(spicommands); 
     566        result = spi_send_multicommand(cmds); 
    568567        if (result) { 
    569568                fprintf(stderr, "%s failed during command execution\n", __func__); 
     
    597596{ 
    598597        int result; 
    599         struct spi_command spicommands[] = { 
     598        struct spi_command cmds[] = { 
    600599        { 
    601600                .writecnt       = JEDEC_WREN_OUTSIZE, 
     
    615614        }}; 
    616615 
    617         result = spi_send_multicommand(spicommands); 
     616        result = spi_send_multicommand(cmds); 
    618617        if (result) { 
    619618                fprintf(stderr, "%s failed during command execution\n", 
     
    641640{ 
    642641        int result; 
    643         struct spi_command spicommands[] = { 
     642        struct spi_command cmds[] = { 
    644643        { 
    645644                .writecnt       = JEDEC_WREN_OUTSIZE, 
     
    659658        }}; 
    660659 
    661         result = spi_send_multicommand(spicommands); 
     660        result = spi_send_multicommand(cmds); 
    662661        if (result) { 
    663662                fprintf(stderr, "%s failed during command execution\n", __func__); 
     
    703702{ 
    704703        int result; 
    705         struct spi_command spicommands[] = { 
     704        struct spi_command cmds[] = { 
    706705        { 
    707706                .writecnt       = JEDEC_WREN_OUTSIZE, 
     
    721720        }}; 
    722721 
    723         result = spi_send_multicommand(spicommands); 
     722        result = spi_send_multicommand(cmds); 
    724723        if (result) { 
    725724                fprintf(stderr, "%s failed during command execution\n", 
     
    780779{ 
    781780        int result; 
    782         struct spi_command spicommands[] = { 
     781        struct spi_command cmds[] = { 
    783782        { 
    784783                .writecnt       = JEDEC_EWSR_OUTSIZE, 
     
    798797        }}; 
    799798 
    800         result = spi_send_multicommand(spicommands); 
     799        result = spi_send_multicommand(cmds); 
    801800        if (result) { 
    802801                fprintf(stderr, "%s failed during command execution\n", 
     
    809808{ 
    810809        int result; 
    811         struct spi_command spicommands[] = { 
     810        struct spi_command cmds[] = { 
    812811        { 
    813812                .writecnt       = JEDEC_WREN_OUTSIZE, 
     
    827826        }}; 
    828827 
    829         result = spi_send_multicommand(spicommands); 
     828        result = spi_send_multicommand(cmds); 
    830829        if (result) { 
    831830                fprintf(stderr, "%s failed during command execution\n", 
     
    845844                (address >> 0) & 0xff, 
    846845        }; 
    847         struct spi_command spicommands[] = { 
     846        struct spi_command cmds[] = { 
    848847        { 
    849848                .writecnt       = JEDEC_WREN_OUTSIZE, 
     
    874873        memcpy(&cmd[4], bytes, len); 
    875874 
    876         result = spi_send_multicommand(spicommands); 
     875        result = spi_send_multicommand(cmds); 
    877876        if (result) { 
    878877                fprintf(stderr, "%s failed during command execution\n", 
Note: See TracChangeset for help on using the changeset viewer.