Author: hailfinger Date: 2009-10-01 16:51:25 +0200 (Thu, 01 Oct 2009) New Revision: 741
Modified: trunk/bitbang_spi.c trunk/flash.h trunk/flashrom.c Log: Make bitbang_spi naming consistent.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net Acked-by: Uwe Hermann uwe@hermann-uwe.de
Modified: trunk/bitbang_spi.c =================================================================== --- trunk/bitbang_spi.c 2009-10-01 14:11:43 UTC (rev 740) +++ trunk/bitbang_spi.c 2009-10-01 14:51:25 UTC (rev 741) @@ -26,40 +26,40 @@ #include "spi.h"
/* Length of half a clock period in usecs */ -int bitbang_half_period = 0; +int bitbang_spi_half_period = 0;
-enum spi_bitbang_master spi_bitbang_master = SPI_BITBANG_INVALID; +enum bitbang_spi_master bitbang_spi_master = BITBANG_SPI_INVALID;
-const struct spi_bitbang_master_entry spi_bitbang_master_table[] = { - {}, /* This entry corresponds to SPI_BITBANG_INVALID. */ +const struct bitbang_spi_master_entry bitbang_spi_master_table[] = { + {}, /* This entry corresponds to BITBANG_SPI_INVALID. */ };
-const int spi_bitbang_master_count = ARRAY_SIZE(spi_bitbang_master_table); +const int bitbang_spi_master_count = ARRAY_SIZE(bitbang_spi_master_table);
-void bitbang_set_cs(int val) +void bitbang_spi_set_cs(int val) { - spi_bitbang_master_table[spi_bitbang_master].set_cs(val); + bitbang_spi_master_table[bitbang_spi_master].set_cs(val); }
-void bitbang_set_sck(int val) +void bitbang_spi_set_sck(int val) { - spi_bitbang_master_table[spi_bitbang_master].set_sck(val); + bitbang_spi_master_table[bitbang_spi_master].set_sck(val); }
-void bitbang_set_mosi(int val) +void bitbang_spi_set_mosi(int val) { - spi_bitbang_master_table[spi_bitbang_master].set_mosi(val); + bitbang_spi_master_table[bitbang_spi_master].set_mosi(val); }
-int bitbang_get_miso(void) +int bitbang_spi_get_miso(void) { - return spi_bitbang_master_table[spi_bitbang_master].get_miso(); + return bitbang_spi_master_table[bitbang_spi_master].get_miso(); }
int bitbang_spi_init(void) { - bitbang_set_cs(1); - bitbang_set_sck(0); + bitbang_spi_set_cs(1); + bitbang_spi_set_sck(0); buses_supported = CHIP_BUSTYPE_SPI; return 0; } @@ -70,13 +70,13 @@ int i;
for (i = 7; i >= 0; i--) { - bitbang_set_mosi((val >> i) & 1); - programmer_delay(bitbang_half_period); - bitbang_set_sck(1); + bitbang_spi_set_mosi((val >> i) & 1); + programmer_delay(bitbang_spi_half_period); + bitbang_spi_set_sck(1); ret <<= 1; - ret |= bitbang_get_miso(); - programmer_delay(bitbang_half_period); - bitbang_set_sck(0); + ret |= bitbang_spi_get_miso(); + programmer_delay(bitbang_spi_half_period); + bitbang_spi_set_sck(0); } return ret; } @@ -117,13 +117,13 @@ /* Make sure any non-read data is 0xff. */ memset(bufin + writecnt, 0xff, readcnt);
- bitbang_set_cs(0); + bitbang_spi_set_cs(0); for (i = 0; i < readcnt + writecnt; i++) { bufin[i] = bitbang_spi_readwrite_byte(bufout[i]); } - programmer_delay(bitbang_half_period); - bitbang_set_cs(1); - programmer_delay(bitbang_half_period); + programmer_delay(bitbang_spi_half_period); + bitbang_spi_set_cs(1); + programmer_delay(bitbang_spi_half_period); memcpy(readarr, bufin + writecnt, readcnt);
return 0; @@ -149,7 +149,7 @@ l = total_size - i;
if ((r = spi_nbyte_program(i, &buf[i], l))) { - fprintf(stderr, "%s: write fail %d\n", __FUNCTION__, r); + fprintf(stderr, "%s: write fail %d\n", __func__, r); return 1; }
Modified: trunk/flash.h =================================================================== --- trunk/flash.h 2009-10-01 14:11:43 UTC (rev 740) +++ trunk/flash.h 2009-10-01 14:51:25 UTC (rev 741) @@ -148,15 +148,15 @@ void chip_readn(uint8_t *buf, const chipaddr addr, size_t len); void programmer_delay(int usecs);
-enum spi_bitbang_master { - SPI_BITBANG_INVALID /* This must always be the last entry. */ +enum bitbang_spi_master { + BITBANG_SPI_INVALID /* This must always be the last entry. */ };
-extern const int spi_bitbang_master_count; +extern const int bitbang_spi_master_count;
-extern enum spi_bitbang_master spi_bitbang_master; +extern enum bitbang_spi_master bitbang_spi_master;
-struct spi_bitbang_master_entry { +struct bitbang_spi_master_entry { void (*set_cs) (int val); void (*set_sck) (int val); void (*set_mosi) (int val); @@ -470,8 +470,8 @@ int ft2232_spi_write_256(struct flashchip *flash, uint8_t *buf);
/* bitbang_spi.c */ -extern int bitbang_half_period; -extern const struct spi_bitbang_master_entry spi_bitbang_master_table[]; +extern int bitbang_spi_half_period; +extern const struct bitbang_spi_master_entry bitbang_spi_master_table[]; int bitbang_spi_init(void); int bitbang_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr); int bitbang_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
Modified: trunk/flashrom.c =================================================================== --- trunk/flashrom.c 2009-10-01 14:11:43 UTC (rev 740) +++ trunk/flashrom.c 2009-10-01 14:51:25 UTC (rev 741) @@ -713,7 +713,7 @@ exit(1); } #if BITBANG_SPI_SUPPORT == 1 - if (spi_bitbang_master_count - 1 != SPI_BITBANG_INVALID) { + if (bitbang_spi_master_count - 1 != BITBANG_SPI_INVALID) { fprintf(stderr, "Bitbanging SPI master table miscompilation!\n"); exit(1); }