Author: stefanct Date: Mon Sep 19 00:42:18 2011 New Revision: 1450 URL: http://flashrom.org/trac/flashrom/changeset/1450
Log: Revert "Unsignify lengths and addresses in chip functions and structs"
- probe_timing was changed to unsigned although we use negative values for special cases - some code was not changed along hence did no longer compile: * dediprog's read and write functions * linux_spi's read and write functions - it introduced a number of new sign conversion warnings (http://paste.flashrom.org/view.php?id=832)
To be safe this patch reverts all changes made in r1448, a corrected patch will follow later.
Thanks to idwer for pointing out the problem first!
Signed-off-by: Stefan Tauner stefan.tauner@student.tuwien.ac.at Acked-by: Stefan Tauner stefan.tauner@student.tuwien.ac.at
Modified: trunk/82802ab.c trunk/chipdrivers.h trunk/dummyflasher.c trunk/flash.h trunk/flashrom.c trunk/it87spi.c trunk/jedec.c trunk/m29f400bt.c trunk/programmer.h trunk/serprog.c trunk/spi.c trunk/spi25.c trunk/sst28sf040.c trunk/wbsio_spi.c
Modified: trunk/82802ab.c ============================================================================== --- trunk/82802ab.c Sun Sep 18 17:15:31 2011 (r1449) +++ trunk/82802ab.c Mon Sep 19 00:42:18 2011 (r1450) @@ -141,7 +141,7 @@ }
/* chunksize is 1 */ -int write_82802ab(struct flashchip *flash, uint8_t *src, unsigned int start, unsigned int len) +int write_82802ab(struct flashchip *flash, uint8_t *src, int start, int len) { int i; chipaddr dst = flash->virtual_memory + start;
Modified: trunk/chipdrivers.h ============================================================================== --- trunk/chipdrivers.h Sun Sep 18 17:15:31 2011 (r1449) +++ trunk/chipdrivers.h Mon Sep 19 00:42:18 2011 (r1450) @@ -41,9 +41,9 @@ int spi_block_erase_d8(struct flashchip *flash, unsigned int addr, unsigned int blocklen); int spi_block_erase_60(struct flashchip *flash, unsigned int addr, unsigned int blocklen); int spi_block_erase_c7(struct flashchip *flash, unsigned int addr, unsigned int blocklen); -int spi_chip_write_1(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len); -int spi_chip_write_256(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len); -int spi_chip_read(struct flashchip *flash, uint8_t *buf, unsigned int start, int unsigned len); +int spi_chip_write_1(struct flashchip *flash, uint8_t *buf, int start, int len); +int spi_chip_write_256(struct flashchip *flash, uint8_t *buf, int start, int len); +int spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len); uint8_t spi_read_status_register(void); int spi_write_status_register(struct flashchip *flash, int status); void spi_prettyprint_status_register_bit(uint8_t status, int bit); @@ -51,12 +51,12 @@ void spi_prettyprint_status_register_welwip(uint8_t status); int spi_prettyprint_status_register(struct flashchip *flash); int spi_disable_blockprotect(struct flashchip *flash); -int spi_byte_program(unsigned int addr, uint8_t databyte); -int spi_nbyte_program(unsigned int addr, uint8_t *bytes, unsigned int len); -int spi_nbyte_read(unsigned int addr, uint8_t *bytes, unsigned int len); -int spi_read_chunked(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize); -int spi_write_chunked(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize); -int spi_aai_write(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len); +int spi_byte_program(int addr, uint8_t databyte); +int spi_nbyte_program(int addr, uint8_t *bytes, int len); +int spi_nbyte_read(int addr, uint8_t *bytes, int len); +int spi_read_chunked(struct flashchip *flash, uint8_t *buf, int start, int len, int chunksize); +int spi_write_chunked(struct flashchip *flash, uint8_t *buf, int start, int len, int chunksize); +int spi_aai_write(struct flashchip *flash, uint8_t *buf, int start, int len);
/* a25.c */ int spi_prettyprint_status_register_amic_a25l05p(struct flashchip *flash); @@ -81,7 +81,7 @@ uint8_t wait_82802ab(struct flashchip *flash); int probe_82802ab(struct flashchip *flash); int erase_block_82802ab(struct flashchip *flash, unsigned int page, unsigned int pagesize); -int write_82802ab(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len); +int write_82802ab(struct flashchip *flash, uint8_t *buf, int start, int len); void print_status_82802ab(uint8_t status); int unlock_82802ab(struct flashchip *flash); int unlock_28f004s5(struct flashchip *flash); @@ -94,8 +94,8 @@ int write_byte_program_jedec(chipaddr bios, uint8_t *src, chipaddr dst); int probe_jedec(struct flashchip *flash); -int write_jedec(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len); -int write_jedec_1(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len); +int write_jedec(struct flashchip *flash, uint8_t *buf, int start, int len); +int write_jedec_1(struct flashchip *flash, uint8_t *buf, int start, int len); int erase_sector_jedec(struct flashchip *flash, unsigned int page, unsigned int pagesize); int erase_block_jedec(struct flashchip *flash, unsigned int page, unsigned int blocksize); int erase_chip_block_jedec(struct flashchip *flash, unsigned int page, unsigned int blocksize); @@ -104,7 +104,7 @@ int probe_m29f400bt(struct flashchip *flash); int block_erase_m29f400bt(struct flashchip *flash, unsigned int start, unsigned int len); int block_erase_chip_m29f400bt(struct flashchip *flash, unsigned int start, unsigned int len); -int write_m29f400bt(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len); +int write_m29f400bt(struct flashchip *flash, uint8_t *buf, int start, int len); void protect_m29f400bt(chipaddr bios);
/* pm49fl00x.c */ @@ -114,7 +114,7 @@ /* sst28sf040.c */ int erase_chip_28sf040(struct flashchip *flash, unsigned int addr, unsigned int blocklen); int erase_sector_28sf040(struct flashchip *flash, unsigned int address, unsigned int sector_size); -int write_28sf040(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len); +int write_28sf040(struct flashchip *flash, uint8_t *buf, int start, int len); int unprotect_28sf040(struct flashchip *flash); int protect_28sf040(struct flashchip *flash);
Modified: trunk/dummyflasher.c ============================================================================== --- trunk/dummyflasher.c Sun Sep 18 17:15:31 2011 (r1449) +++ trunk/dummyflasher.c Mon Sep 19 00:42:18 2011 (r1450) @@ -63,7 +63,7 @@ static int dummy_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr); static int dummy_spi_write_256(struct flashchip *flash, uint8_t *buf, - unsigned int start, unsigned int len); + int start, int len);
static const struct spi_programmer spi_programmer_dummyflasher = { .type = SPI_CONTROLLER_DUMMY, @@ -528,7 +528,7 @@ }
static int dummy_spi_write_256(struct flashchip *flash, uint8_t *buf, - unsigned int start, unsigned int len) + int start, int len) { return spi_write_chunked(flash, buf, start, len, spi_write_256_chunksize);
Modified: trunk/flash.h ============================================================================== --- trunk/flash.h Sun Sep 18 17:15:31 2011 (r1449) +++ trunk/flash.h Mon Sep 19 00:42:18 2011 (r1450) @@ -108,9 +108,9 @@ uint32_t model_id;
/* Total chip size in kilobytes */ - unsigned int total_size; + int total_size; /* Chip page size in bytes */ - unsigned int page_size; + int page_size; int feature_bits;
/* @@ -122,7 +122,7 @@ int (*probe) (struct flashchip *flash);
/* Delay after "enter/exit ID mode" commands in microseconds. */ - unsigned int probe_timing; + int probe_timing;
/* * Erase blocks and associated erase function. Any chip erase function @@ -143,8 +143,8 @@
int (*printlock) (struct flashchip *flash); int (*unlock) (struct flashchip *flash); - int (*write) (struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len); - int (*read) (struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len); + int (*write) (struct flashchip *flash, uint8_t *buf, int start, int len); + int (*read) (struct flashchip *flash, uint8_t *buf, int start, int len); struct { uint16_t min; uint16_t max; @@ -202,7 +202,7 @@ extern const char flashrom_version[]; extern char *chip_to_probe; void map_flash_registers(struct flashchip *flash); -int read_memmapped(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len); +int read_memmapped(struct flashchip *flash, uint8_t *buf, int start, int len); int erase_flash(struct flashchip *flash); int probe_flash(int startchip, struct flashchip *fill_flash, int force); int read_flash_to_file(struct flashchip *flash, const char *filename); @@ -210,7 +210,7 @@ int max(int a, int b); void tolower_string(char *str); char *extract_param(char **haystack, const char *needle, const char *delim); -int verify_range(struct flashchip *flash, uint8_t *cmpbuf, unsigned int start, unsigned int len, const char *message); +int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len, const char *message); int need_erase(uint8_t *have, uint8_t *want, int len, enum write_granularity gran); char *strcat_realloc(char *dest, const char *src); void print_version(void);
Modified: trunk/flashrom.c ============================================================================== --- trunk/flashrom.c Sun Sep 18 17:15:31 2011 (r1449) +++ trunk/flashrom.c Mon Sep 19 00:42:18 2011 (r1450) @@ -564,7 +564,7 @@ flash->virtual_registers = (chipaddr)programmer_map_flash_region("flash chip registers", (0xFFFFFFFF - 0x400000 - size + 1), size); }
-int read_memmapped(struct flashchip *flash, uint8_t *buf, unsigned int start, int unsigned len) +int read_memmapped(struct flashchip *flash, uint8_t *buf, int start, int len) { chip_readn(buf, flash->virtual_memory + start, len);
@@ -710,7 +710,7 @@ * @message string to print in the "FAILED" message * @return 0 for success, -1 for failure */ -int verify_range(struct flashchip *flash, uint8_t *cmpbuf, unsigned int start, unsigned int len, +int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len, const char *message) { int i;
Modified: trunk/it87spi.c ============================================================================== --- trunk/it87spi.c Sun Sep 18 17:15:31 2011 (r1449) +++ trunk/it87spi.c Mon Sep 19 00:42:18 2011 (r1450) @@ -106,9 +106,9 @@ static int it8716f_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr); static int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf, - unsigned int start, unsigned int len); + int start, int len); static int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf, - unsigned int start, unsigned int len); + int start, int len);
static const struct spi_programmer spi_programmer_it87xx = { .type = SPI_CONTROLLER_IT87XX, @@ -340,7 +340,7 @@ * Need to read this big flash using firmware cycles 3 byte at a time. */ static int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf, - unsigned int start, unsigned int len) + int start, int len) { fast_spi = 0;
@@ -358,7 +358,7 @@ }
static int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf, - unsigned int start, unsigned int len) + int start, int len) { /* * IT8716F only allows maximum of 512 kb SPI chip size for memory
Modified: trunk/jedec.c ============================================================================== --- trunk/jedec.c Sun Sep 18 17:15:31 2011 (r1449) +++ trunk/jedec.c Mon Sep 19 00:42:18 2011 (r1450) @@ -355,7 +355,7 @@ }
/* chunksize is 1 */ -int write_jedec_1(struct flashchip *flash, uint8_t *src, unsigned int start, unsigned int len) +int write_jedec_1(struct flashchip *flash, uint8_t *src, int start, int len) { int i, failed = 0; chipaddr dst = flash->virtual_memory + start; @@ -376,7 +376,7 @@ return failed; }
-int write_page_write_jedec_common(struct flashchip *flash, uint8_t *src, unsigned int start, unsigned int page_size) +int write_page_write_jedec_common(struct flashchip *flash, uint8_t *src, int start, int page_size) { int i, tried = 0, failed; uint8_t *s = src; @@ -424,7 +424,7 @@ * This function is a slightly modified copy of spi_write_chunked. * Each page is written separately in chunks with a maximum size of chunksize. */ -int write_jedec(struct flashchip *flash, uint8_t *buf, unsigned int start, int unsigned len) +int write_jedec(struct flashchip *flash, uint8_t *buf, int start, int len) { int i, starthere, lenhere; /* FIXME: page_size is the wrong variable. We need max_writechunk_size
Modified: trunk/m29f400bt.c ============================================================================== --- trunk/m29f400bt.c Sun Sep 18 17:15:31 2011 (r1449) +++ trunk/m29f400bt.c Mon Sep 19 00:42:18 2011 (r1450) @@ -28,7 +28,7 @@ functions. */
/* chunksize is 1 */ -int write_m29f400bt(struct flashchip *flash, uint8_t *src, unsigned int start, unsigned int len) +int write_m29f400bt(struct flashchip *flash, uint8_t *src, int start, int len) { int i; chipaddr bios = flash->virtual_memory;
Modified: trunk/programmer.h ============================================================================== --- trunk/programmer.h Sun Sep 18 17:15:31 2011 (r1449) +++ trunk/programmer.h Mon Sep 19 00:42:18 2011 (r1450) @@ -556,23 +556,23 @@ #define MAX_DATA_WRITE_UNLIMITED 256 struct spi_programmer { enum spi_controller type; - unsigned int max_data_read; - unsigned int max_data_write; + int max_data_read; + int max_data_write; int (*command)(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr); int (*multicommand)(struct spi_command *cmds);
/* Optimized functions for this programmer */ - int (*read)(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len); - int (*write_256)(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len); + int (*read)(struct flashchip *flash, uint8_t *buf, int start, int len); + int (*write_256)(struct flashchip *flash, uint8_t *buf, int start, int len); };
extern const struct spi_programmer *spi_programmer; int default_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr); int default_spi_send_multicommand(struct spi_command *cmds); -int default_spi_read(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len); -int default_spi_write_256(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len); +int default_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); +int default_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len); void register_spi_programmer(const struct spi_programmer *programmer);
/* ichspi.c */ @@ -610,7 +610,7 @@ void serprog_delay(int delay); int serprog_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr); -int serprog_spi_read(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len); +int serprog_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); #endif
/* serial.c */
Modified: trunk/serprog.c ============================================================================== --- trunk/serprog.c Sun Sep 18 17:15:31 2011 (r1449) +++ trunk/serprog.c Mon Sep 19 00:42:18 2011 (r1450) @@ -795,7 +795,7 @@ * the advantage that it is much faster for most chips, but breaks those with * non-contiguous address space (like AT45DB161D). When spi_read_chunked is * fixed this method can be removed. */ -int serprog_spi_read(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len) +int serprog_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len) { int i; int cur_len;
Modified: trunk/spi.c ============================================================================== --- trunk/spi.c Sun Sep 18 17:15:31 2011 (r1449) +++ trunk/spi.c Mon Sep 19 00:42:18 2011 (r1450) @@ -97,9 +97,9 @@ return result; }
-int default_spi_read(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len) +int default_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len) { - unsigned int max_data = spi_programmer->max_data_read; + int max_data = spi_programmer->max_data_read; if (max_data == MAX_DATA_UNSPECIFIED) { msg_perr("%s called, but SPI read chunk size not defined " "on this hardware. Please report a bug at " @@ -109,9 +109,9 @@ return spi_read_chunked(flash, buf, start, len, max_data); }
-int default_spi_write_256(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len) +int default_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len) { - unsigned int max_data = spi_programmer->max_data_write; + int max_data = spi_programmer->max_data_write; if (max_data == MAX_DATA_UNSPECIFIED) { msg_perr("%s called, but SPI write chunk size not defined " "on this hardware. Please report a bug at " @@ -121,7 +121,7 @@ return spi_write_chunked(flash, buf, start, len, max_data); }
-int spi_chip_read(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len) +int spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len) { int addrbase = 0; if (!spi_programmer->read) { @@ -160,7 +160,7 @@ * .write_256 = spi_chip_write_1 */ /* real chunksize is up to 256, logical chunksize is 256 */ -int spi_chip_write_256(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len) +int spi_chip_write_256(struct flashchip *flash, uint8_t *buf, int start, int len) { if (!spi_programmer->write_256) { msg_perr("%s called, but SPI page write is unsupported on this "
Modified: trunk/spi25.c ============================================================================== --- trunk/spi25.c Sun Sep 18 17:15:31 2011 (r1449) +++ trunk/spi25.c Mon Sep 19 00:42:18 2011 (r1450) @@ -844,7 +844,7 @@ return ret; }
-int spi_byte_program(unsigned int addr, uint8_t databyte) +int spi_byte_program(int addr, uint8_t databyte) { int result; struct spi_command cmds[] = { @@ -879,7 +879,7 @@ return result; }
-int spi_nbyte_program(unsigned int addr, uint8_t *bytes, unsigned int len) +int spi_nbyte_program(int addr, uint8_t *bytes, int len) { int result; /* FIXME: Switch to malloc based on len unless that kills speed. */ @@ -954,7 +954,7 @@ return 0; }
-int spi_nbyte_read(unsigned int address, uint8_t *bytes, unsigned int len) +int spi_nbyte_read(int address, uint8_t *bytes, int len) { const unsigned char cmd[JEDEC_READ_OUTSIZE] = { JEDEC_READ, @@ -972,7 +972,7 @@ * FIXME: Use the chunk code from Michael Karcher instead. * Each page is read separately in chunks with a maximum size of chunksize. */ -int spi_read_chunked(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize) +int spi_read_chunked(struct flashchip *flash, uint8_t *buf, int start, int len, int chunksize) { int rc = 0; int i, j, starthere, lenhere; @@ -1012,7 +1012,7 @@ * FIXME: Use the chunk code from Michael Karcher instead. * Each page is written separately in chunks with a maximum size of chunksize. */ -int spi_write_chunked(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize) +int spi_write_chunked(struct flashchip *flash, uint8_t *buf, int start, int len, int chunksize) { int rc = 0; int i, j, starthere, lenhere; @@ -1061,7 +1061,7 @@ * (e.g. due to size constraints in IT87* for over 512 kB) */ /* real chunksize is 1, logical chunksize is 1 */ -int spi_chip_write_1(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len) +int spi_chip_write_1(struct flashchip *flash, uint8_t *buf, int start, int len) { int i, result = 0;
@@ -1076,7 +1076,7 @@ return 0; }
-int spi_aai_write(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len) +int spi_aai_write(struct flashchip *flash, uint8_t *buf, int start, int len) { uint32_t pos = start; int result;
Modified: trunk/sst28sf040.c ============================================================================== --- trunk/sst28sf040.c Sun Sep 18 17:15:31 2011 (r1449) +++ trunk/sst28sf040.c Mon Sep 19 00:42:18 2011 (r1450) @@ -76,7 +76,7 @@ }
/* chunksize is 1 */ -int write_28sf040(struct flashchip *flash, uint8_t *src, unsigned int start, unsigned int len) +int write_28sf040(struct flashchip *flash, uint8_t *src, int start, int len) { int i; chipaddr bios = flash->virtual_memory;
Modified: trunk/wbsio_spi.c ============================================================================== --- trunk/wbsio_spi.c Sun Sep 18 17:15:31 2011 (r1449) +++ trunk/wbsio_spi.c Mon Sep 19 00:42:18 2011 (r1450) @@ -62,7 +62,7 @@
static int wbsio_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr); -static int wbsio_spi_read(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len); +static int wbsio_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
static const struct spi_programmer spi_programmer_wbsio = { .type = SPI_CONTROLLER_WBSIO, @@ -194,7 +194,7 @@ return 0; }
-static int wbsio_spi_read(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len) +static int wbsio_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len) { return read_memmapped(flash, buf, start, len); }