Unsignify lengths and addresses in chip functions and structs
Push those changes forward where needed to prevent new sign
conversion warnings where possible.
Corresponding to flashrom svn r1470.
Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
diff --git a/82802ab.c b/82802ab.c
index ff2f535..8f671c9 100644
--- a/82802ab.c
+++ b/82802ab.c
@@ -141,7 +141,7 @@
}
/* chunksize is 1 */
-int write_82802ab(struct flashchip *flash, uint8_t *src, int start, int len)
+int write_82802ab(struct flashchip *flash, uint8_t *src, unsigned int start, unsigned int len)
{
int i;
chipaddr dst = flash->virtual_memory + start;
diff --git a/buspirate_spi.c b/buspirate_spi.c
index a556185..fd06b59 100644
--- a/buspirate_spi.c
+++ b/buspirate_spi.c
@@ -295,7 +295,8 @@
const unsigned char *writearr, unsigned char *readarr)
{
static unsigned char *buf = NULL;
- int i = 0, ret = 0;
+ unsigned int i = 0;
+ int ret = 0;
if (writecnt > 16 || readcnt > 16 || (readcnt + writecnt) > 16)
return SPI_INVALID_LENGTH;
diff --git a/chipdrivers.h b/chipdrivers.h
index 2746e52..d2886c4 100644
--- a/chipdrivers.h
+++ b/chipdrivers.h
@@ -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, 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);
+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);
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,17 +51,17 @@
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(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);
+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);
/* opaque.c */
int probe_opaque(struct flashchip *flash);
-int read_opaque(struct flashchip *flash, uint8_t *buf, int start, int len);
-int write_opaque(struct flashchip *flash, uint8_t *buf, int start, int len);
+int read_opaque(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
+int write_opaque(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
int erase_opaque(struct flashchip *flash, unsigned int blockaddr, unsigned int blocklen);
/* a25.c */
@@ -87,7 +87,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, int start, int len);
+int write_82802ab(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
void print_status_82802ab(uint8_t status);
int unlock_82802ab(struct flashchip *flash);
int unlock_28f004s5(struct flashchip *flash);
@@ -100,8 +100,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, int start, int len);
-int write_jedec_1(struct flashchip *flash, uint8_t *buf, int start, int len);
+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 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);
@@ -110,7 +110,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, int start, int len);
+int write_m29f400bt(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
void protect_m29f400bt(chipaddr bios);
/* pm49fl00x.c */
@@ -120,7 +120,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, int start, int len);
+int write_28sf040(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
int unprotect_28sf040(struct flashchip *flash);
int protect_28sf040(struct flashchip *flash);
diff --git a/dediprog.c b/dediprog.c
index 58eeb44..ca2d3e0 100644
--- a/dediprog.c
+++ b/dediprog.c
@@ -206,13 +206,13 @@
* @return 0 on success, 1 on failure
*/
static int dediprog_spi_bulk_read(struct flashchip *flash, uint8_t *buf,
- int start, int len)
+ unsigned int start, unsigned int len)
{
int ret;
- int i;
+ unsigned int i;
/* chunksize must be 512, other sizes will NOT work at all. */
- const int chunksize = 0x200;
- const int count = len / chunksize;
+ const unsigned int chunksize = 0x200;
+ const unsigned int count = len / chunksize;
const char count_and_chunk[] = {count & 0xff,
(count >> 8) & 0xff,
chunksize & 0xff,
@@ -253,14 +253,14 @@
return 0;
}
-static int dediprog_spi_read(struct flashchip *flash, uint8_t *buf, int start,
- int len)
+static int dediprog_spi_read(struct flashchip *flash, uint8_t *buf,
+ unsigned int start, unsigned int len)
{
int ret;
/* chunksize must be 512, other sizes will NOT work at all. */
- const int chunksize = 0x200;
- int residue = start % chunksize ? chunksize - start % chunksize : 0;
- int bulklen;
+ const unsigned int chunksize = 0x200;
+ unsigned int residue = start % chunksize ? chunksize - start % chunksize : 0;
+ unsigned int bulklen;
dediprog_set_leds(PASS_OFF|BUSY_ON|ERROR_OFF);
@@ -300,7 +300,7 @@
}
static int dediprog_spi_write_256(struct flashchip *flash, uint8_t *buf,
- int start, int len)
+ unsigned int start, unsigned int len)
{
int ret;
diff --git a/dummyflasher.c b/dummyflasher.c
index 822bc73..8437c58 100644
--- a/dummyflasher.c
+++ b/dummyflasher.c
@@ -46,24 +46,24 @@
};
static enum emu_chip emu_chip = EMULATE_NONE;
static char *emu_persistent_image = NULL;
-static int emu_chip_size = 0;
+static unsigned int emu_chip_size = 0;
#if EMULATE_SPI_CHIP
-static int emu_max_byteprogram_size = 0;
-static int emu_max_aai_size = 0;
-static int emu_jedec_se_size = 0;
-static int emu_jedec_be_52_size = 0;
-static int emu_jedec_be_d8_size = 0;
-static int emu_jedec_ce_60_size = 0;
-static int emu_jedec_ce_c7_size = 0;
+static unsigned int emu_max_byteprogram_size = 0;
+static unsigned int emu_max_aai_size = 0;
+static unsigned int emu_jedec_se_size = 0;
+static unsigned int emu_jedec_be_52_size = 0;
+static unsigned int emu_jedec_be_d8_size = 0;
+static unsigned int emu_jedec_ce_60_size = 0;
+static unsigned int emu_jedec_ce_c7_size = 0;
#endif
#endif
-static int spi_write_256_chunksize = 256;
+static unsigned int spi_write_256_chunksize = 256;
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,
- int start, int len);
+ unsigned int start, unsigned int len);
static const struct spi_programmer spi_programmer_dummyflasher = {
.type = SPI_CONTROLLER_DUMMY,
@@ -320,8 +320,8 @@
static int emulate_spi_chip_response(unsigned int writecnt, unsigned int readcnt,
const unsigned char *writearr, unsigned char *readarr)
{
- int offs;
- static int aai_offs;
+ unsigned int offs;
+ static int unsigned aai_offs;
static int aai_active = 0;
if (writecnt == 0) {
@@ -549,7 +549,7 @@
}
static int dummy_spi_write_256(struct flashchip *flash, uint8_t *buf,
- int start, int len)
+ unsigned int start, unsigned int len)
{
return spi_write_chunked(flash, buf, start, len,
spi_write_256_chunksize);
diff --git a/flash.h b/flash.h
index c91e954..543b70c 100644
--- a/flash.h
+++ b/flash.h
@@ -108,9 +108,9 @@
uint32_t model_id;
/* Total chip size in kilobytes */
- int total_size;
+ unsigned int total_size;
/* Chip page size in bytes */
- int page_size;
+ unsigned int page_size;
int feature_bits;
/*
@@ -121,8 +121,10 @@
int (*probe) (struct flashchip *flash);
- /* Delay after "enter/exit ID mode" commands in microseconds. */
- int probe_timing;
+ /* Delay after "enter/exit ID mode" commands in microseconds.
+ * NB: negative values have special meanings, see TIMING_* below.
+ */
+ signed int probe_timing;
/*
* Erase blocks and associated erase function. Any chip erase function
@@ -143,8 +145,8 @@
int (*printlock) (struct flashchip *flash);
int (*unlock) (struct flashchip *flash);
- int (*write) (struct flashchip *flash, uint8_t *buf, int start, int len);
- int (*read) (struct flashchip *flash, uint8_t *buf, int start, int len);
+ 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);
struct {
uint16_t min;
uint16_t max;
@@ -202,7 +204,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, int start, int len);
+int read_memmapped(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned 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,8 +212,8 @@
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, int start, int len, const char *message);
-int need_erase(uint8_t *have, uint8_t *want, int len, enum write_granularity gran);
+int verify_range(struct flashchip *flash, uint8_t *cmpbuf, unsigned int start, unsigned int len, const char *message);
+int need_erase(uint8_t *have, uint8_t *want, unsigned int len, enum write_granularity gran);
char *strcat_realloc(char *dest, const char *src);
void print_version(void);
void print_banner(void);
diff --git a/flashrom.c b/flashrom.c
index 1fd3bae..fadd098 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -412,7 +412,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, int start, int len)
+int read_memmapped(struct flashchip *flash, uint8_t *buf, unsigned int start, int unsigned len)
{
chip_readn(buf, flash->virtual_memory + start, len);
@@ -535,7 +535,7 @@
}
/* start is an offset to the base address of the flash chip */
-int check_erased_range(struct flashchip *flash, int start, int len)
+int check_erased_range(struct flashchip *flash, unsigned int start, unsigned int len)
{
int ret;
uint8_t *cmpbuf = malloc(len);
@@ -558,10 +558,10 @@
* @message string to print in the "FAILED" message
* @return 0 for success, -1 for failure
*/
-int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len,
+int verify_range(struct flashchip *flash, uint8_t *cmpbuf, unsigned int start, unsigned int len,
const char *message)
{
- int i;
+ unsigned int i;
uint8_t *readbuf = malloc(len);
int ret = 0, failcount = 0;
@@ -639,10 +639,10 @@
* @gran write granularity (enum, not count)
* @return 0 if no erase is needed, 1 otherwise
*/
-int need_erase(uint8_t *have, uint8_t *want, int len, enum write_granularity gran)
+int need_erase(uint8_t *have, uint8_t *want, unsigned int len, enum write_granularity gran)
{
int result = 0;
- int i, j, limit;
+ unsigned int i, j, limit;
switch (gran) {
case write_gran_1bit:
@@ -705,11 +705,13 @@
* in relation to the max write length of the programmer and the max write
* length of the chip.
*/
-static int get_next_write(uint8_t *have, uint8_t *want, int len,
- int *first_start, enum write_granularity gran)
+static unsigned int get_next_write(uint8_t *have, uint8_t *want, unsigned int len,
+ unsigned int *first_start,
+ enum write_granularity gran)
{
- int need_write = 0, rel_start = 0, first_len = 0;
- int i, limit, stride;
+ int need_write = 0;
+ unsigned int rel_start = 0, first_len = 0;
+ unsigned int i, limit, stride;
switch (gran) {
case write_gran_1bit:
@@ -1030,7 +1032,7 @@
int verify_flash(struct flashchip *flash, uint8_t *buf)
{
int ret;
- int total_size = flash->total_size * 1024;
+ unsigned int total_size = flash->total_size * 1024;
msg_cinfo("Verifying flash... ");
@@ -1208,7 +1210,8 @@
unsigned int addr,
unsigned int len))
{
- int starthere = 0, lenhere = 0, ret = 0, skip = 1, writecount = 0;
+ unsigned int starthere = 0, lenhere = 0;
+ int ret = 0, skip = 1, writecount = 0;
enum write_granularity gran = write_gran_256bytes; /* FIXME */
/* curcontents and newcontents are opaque to walk_eraseregions, and
diff --git a/ichspi.c b/ichspi.c
index 1ce525f..78cdb3b 100644
--- a/ichspi.c
+++ b/ichspi.c
@@ -1278,7 +1278,8 @@
return 0;
}
-int ich_hwseq_read(struct flashchip *flash, uint8_t *buf, int addr, int len)
+int ich_hwseq_read(struct flashchip *flash, uint8_t *buf, unsigned int addr,
+ unsigned int len)
{
uint16_t hsfc;
uint16_t timeout = 100 * 60;
@@ -1315,7 +1316,8 @@
return 0;
}
-int ich_hwseq_write(struct flashchip *flash, uint8_t *buf, int addr, int len)
+int ich_hwseq_write(struct flashchip *flash, uint8_t *buf, unsigned int addr,
+ unsigned int len)
{
uint16_t hsfc;
uint16_t timeout = 100 * 60;
diff --git a/it87spi.c b/it87spi.c
index 1cff3a3..4810252 100644
--- a/it87spi.c
+++ b/it87spi.c
@@ -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,
- int start, int len);
+ unsigned int start, unsigned int len);
static int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf,
- int start, int len);
+ unsigned int start, unsigned int len);
static const struct spi_programmer spi_programmer_it87xx = {
.type = SPI_CONTROLLER_IT87XX,
@@ -313,9 +313,10 @@
/* Page size is usually 256 bytes */
static int it8716f_spi_page_program(struct flashchip *flash, uint8_t *buf,
- int start)
+ unsigned int start)
{
- int i, result;
+ unsigned int i;
+ int result;
chipaddr bios = flash->virtual_memory;
result = spi_write_enable();
@@ -340,7 +341,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,
- int start, int len)
+ unsigned int start, unsigned int len)
{
fast_spi = 0;
@@ -358,7 +359,7 @@
}
static int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf,
- int start, int len)
+ unsigned int start, unsigned int len)
{
/*
* IT8716F only allows maximum of 512 kb SPI chip size for memory
@@ -374,7 +375,7 @@
(flash->page_size > 256)) {
spi_chip_write_1(flash, buf, start, len);
} else {
- int lenhere;
+ unsigned int lenhere;
if (start % flash->page_size) {
/* start to the end of the page or to start + len,
diff --git a/jedec.c b/jedec.c
index cf34bcd..8004863 100644
--- a/jedec.c
+++ b/jedec.c
@@ -91,7 +91,7 @@
msg_cdbg("%s: excessive loops, i=0x%x\n", __func__, i);
}
-static int getaddrmask(struct flashchip *flash)
+static unsigned int getaddrmask(struct flashchip *flash)
{
switch (flash->feature_bits & FEATURE_ADDR_MASK) {
case FEATURE_ADDR_FULL:
@@ -355,12 +355,12 @@
}
/* chunksize is 1 */
-int write_jedec_1(struct flashchip *flash, uint8_t *src, int start, int len)
+int write_jedec_1(struct flashchip *flash, uint8_t *src, unsigned int start, unsigned int len)
{
int i, failed = 0;
chipaddr dst = flash->virtual_memory + start;
chipaddr olddst;
- int mask;
+ unsigned int mask;
mask = getaddrmask(flash);
@@ -376,14 +376,14 @@
return failed;
}
-int write_page_write_jedec_common(struct flashchip *flash, uint8_t *src, int start, int page_size)
+int write_page_write_jedec_common(struct flashchip *flash, uint8_t *src, unsigned int start, unsigned int page_size)
{
int i, tried = 0, failed;
uint8_t *s = src;
chipaddr bios = flash->virtual_memory;
chipaddr dst = bios + start;
chipaddr d = dst;
- int mask;
+ unsigned int mask;
mask = getaddrmask(flash);
@@ -424,15 +424,15 @@
* 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, int start, int len)
+int write_jedec(struct flashchip *flash, uint8_t *buf, unsigned int start, int unsigned len)
{
- int i, starthere, lenhere;
+ unsigned int i, starthere, lenhere;
/* FIXME: page_size is the wrong variable. We need max_writechunk_size
* in struct flashchip to do this properly. All chips using
* write_jedec have page_size set to max_writechunk_size, so
* we're OK for now.
*/
- int page_size = flash->page_size;
+ unsigned int page_size = flash->page_size;
/* Warning: This loop has a very unusual condition and body.
* The loop needs to go through each page with at least one affected
@@ -461,7 +461,7 @@
int erase_chip_block_jedec(struct flashchip *flash, unsigned int addr,
unsigned int blocksize)
{
- int mask;
+ unsigned int mask;
mask = getaddrmask(flash);
if ((addr != 0) || (blocksize != flash->total_size * 1024)) {
@@ -474,7 +474,7 @@
int probe_jedec(struct flashchip *flash)
{
- int mask;
+ unsigned int mask;
mask = getaddrmask(flash);
return probe_jedec_common(flash, mask);
@@ -482,7 +482,7 @@
int erase_sector_jedec(struct flashchip *flash, unsigned int page, unsigned int size)
{
- int mask;
+ unsigned int mask;
mask = getaddrmask(flash);
return erase_sector_jedec_common(flash, page, size, mask);
@@ -490,7 +490,7 @@
int erase_block_jedec(struct flashchip *flash, unsigned int page, unsigned int size)
{
- int mask;
+ unsigned int mask;
mask = getaddrmask(flash);
return erase_block_jedec_common(flash, page, size, mask);
@@ -498,7 +498,7 @@
int erase_chip_jedec(struct flashchip *flash)
{
- int mask;
+ unsigned int mask;
mask = getaddrmask(flash);
return erase_chip_jedec_common(flash, mask);
diff --git a/linux_spi.c b/linux_spi.c
index de82def..44a2fcd 100644
--- a/linux_spi.c
+++ b/linux_spi.c
@@ -36,10 +36,10 @@
static int linux_spi_shutdown(void *data);
static int linux_spi_send_command(unsigned int writecnt, unsigned int readcnt,
const unsigned char *txbuf, unsigned char *rxbuf);
-static int linux_spi_read(struct flashchip *flash, uint8_t *buf, int start,
- int len);
+static int linux_spi_read(struct flashchip *flash, uint8_t *buf,
+ unsigned int start, unsigned int len);
static int linux_spi_write_256(struct flashchip *flash, uint8_t *buf,
- int start, int len);
+ unsigned int start, unsigned int len);
static const struct spi_programmer spi_programmer_linux = {
.type = SPI_CONTROLLER_LINUX,
@@ -131,14 +131,14 @@
return 0;
}
-static int linux_spi_read(struct flashchip *flash, uint8_t *buf, int start,
- int len)
+static int linux_spi_read(struct flashchip *flash, uint8_t *buf,
+ unsigned int start, unsigned int len)
{
- return spi_read_chunked(flash, buf, start, len, getpagesize());
+ return spi_read_chunked(flash, buf, start, len, (unsigned)getpagesize());
}
static int linux_spi_write_256(struct flashchip *flash, uint8_t *buf,
- int start, int len)
+ unsigned int start, unsigned int len)
{
- return spi_write_chunked(flash, buf, start, len, getpagesize() - 4);
+ return spi_write_chunked(flash, buf, start, len, ((unsigned)getpagesize()) - 4);
}
diff --git a/m29f400bt.c b/m29f400bt.c
index e0d41d4..61bfa2e 100644
--- a/m29f400bt.c
+++ b/m29f400bt.c
@@ -28,7 +28,7 @@
functions. */
/* chunksize is 1 */
-int write_m29f400bt(struct flashchip *flash, uint8_t *src, int start, int len)
+int write_m29f400bt(struct flashchip *flash, uint8_t *src, unsigned int start, unsigned int len)
{
int i;
chipaddr bios = flash->virtual_memory;
diff --git a/opaque.c b/opaque.c
index 13c6a09..1c31612 100644
--- a/opaque.c
+++ b/opaque.c
@@ -53,7 +53,7 @@
return opaque_programmer->probe(flash);
}
-int read_opaque(struct flashchip *flash, uint8_t *buf, int start, int len)
+int read_opaque(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
{
if (!opaque_programmer->read) {
msg_perr("%s called before register_opaque_programmer. "
@@ -64,7 +64,7 @@
return opaque_programmer->read(flash, buf, start, len);
}
-int write_opaque(struct flashchip *flash, uint8_t *buf, int start, int len)
+int write_opaque(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
{
if (!opaque_programmer->write) {
msg_perr("%s called before register_opaque_programmer. "
diff --git a/pm49fl00x.c b/pm49fl00x.c
index 28052e5..13992a3 100644
--- a/pm49fl00x.c
+++ b/pm49fl00x.c
@@ -22,10 +22,10 @@
#include "flash.h"
-static void write_lockbits_49fl00x(chipaddr bios, int size,
- unsigned char bits, int block_size)
+static void write_lockbits_49fl00x(chipaddr bios, unsigned int size,
+ unsigned char bits, unsigned int block_size)
{
- int i, left = size;
+ unsigned int i, left = size;
for (i = 0; left >= block_size; i++, left -= block_size) {
/* pm49fl002 */
diff --git a/programmer.h b/programmer.h
index b16e4f8..8f55912 100644
--- a/programmer.h
+++ b/programmer.h
@@ -563,23 +563,23 @@
#define MAX_DATA_WRITE_UNLIMITED 256
struct spi_programmer {
enum spi_controller type;
- int max_data_read;
- int max_data_write;
+ unsigned int max_data_read;
+ unsigned 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, int start, int len);
- int (*write_256)(struct flashchip *flash, uint8_t *buf, int start, int len);
+ 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);
};
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, int start, int len);
-int default_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len);
+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);
void register_spi_programmer(const struct spi_programmer *programmer);
/* ichspi.c */
@@ -625,8 +625,8 @@
int max_data_write;
/* Specific functions for this programmer */
int (*probe) (struct flashchip *flash);
- int (*read) (struct flashchip *flash, uint8_t *buf, int start, int len);
- int (*write) (struct flashchip *flash, uint8_t *buf, int start, int len);
+ int (*read) (struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
+ int (*write) (struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len);
int (*erase) (struct flashchip *flash, unsigned int blockaddr, unsigned int blocklen);
};
extern const struct opaque_programmer *opaque_programmer;
diff --git a/serprog.c b/serprog.c
index ab998ff..7925cee 100644
--- a/serprog.c
+++ b/serprog.c
@@ -302,8 +302,8 @@
static int serprog_spi_send_command(unsigned int writecnt, unsigned int readcnt,
const unsigned char *writearr,
unsigned char *readarr);
-static int serprog_spi_read(struct flashchip *flash, uint8_t *buf, int start,
- int len);
+static int serprog_spi_read(struct flashchip *flash, uint8_t *buf,
+ unsigned int start, unsigned int len);
static struct spi_programmer spi_programmer_serprog = {
.type = SPI_CONTROLLER_SERPROG,
.max_data_read = MAX_DATA_READ_UNLIMITED,
@@ -822,11 +822,10 @@
* 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. */
-static int serprog_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len)
+static int serprog_spi_read(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
{
- int i;
- int cur_len;
- const int max_read = spi_programmer_serprog.max_data_read;
+ unsigned int i, cur_len;
+ const unsigned int max_read = spi_programmer_serprog.max_data_read;
for (i = 0; i < len; i += cur_len) {
int ret;
cur_len = min(max_read, (len - i));
diff --git a/spi.c b/spi.c
index f02f091..60f77b0 100644
--- a/spi.c
+++ b/spi.c
@@ -97,9 +97,9 @@
return result;
}
-int default_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len)
+int default_spi_read(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
{
- int max_data = spi_programmer->max_data_read;
+ unsigned 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, int start, int len)
+int default_spi_write_256(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
{
- int max_data = spi_programmer->max_data_write;
+ unsigned 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,9 +121,9 @@
return spi_write_chunked(flash, buf, start, len, max_data);
}
-int spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len)
+int spi_chip_read(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
{
- int addrbase = 0;
+ unsigned int addrbase = 0;
if (!spi_programmer->read) {
msg_perr("%s called, but SPI read is unsupported on this "
"hardware. Please report a bug at "
@@ -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, int start, int len)
+int spi_chip_write_256(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
{
if (!spi_programmer->write_256) {
msg_perr("%s called, but SPI page write is unsupported on this "
diff --git a/spi25.c b/spi25.c
index c9fe9ec..60eb644 100644
--- a/spi25.c
+++ b/spi25.c
@@ -840,7 +840,7 @@
return ret;
}
-int spi_byte_program(int addr, uint8_t databyte)
+int spi_byte_program(unsigned int addr, uint8_t databyte)
{
int result;
struct spi_command cmds[] = {
@@ -875,7 +875,7 @@
return result;
}
-int spi_nbyte_program(int addr, uint8_t *bytes, int len)
+int spi_nbyte_program(unsigned int addr, uint8_t *bytes, unsigned int len)
{
int result;
/* FIXME: Switch to malloc based on len unless that kills speed. */
@@ -950,7 +950,7 @@
return 0;
}
-int spi_nbyte_read(int address, uint8_t *bytes, int len)
+int spi_nbyte_read(unsigned int address, uint8_t *bytes, unsigned int len)
{
const unsigned char cmd[JEDEC_READ_OUTSIZE] = {
JEDEC_READ,
@@ -968,12 +968,11 @@
* 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, int start, int len, int chunksize)
+int spi_read_chunked(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize)
{
int rc = 0;
- int i, j, starthere, lenhere;
- int page_size = flash->page_size;
- int toread;
+ unsigned int i, j, starthere, lenhere, toread;
+ unsigned int page_size = flash->page_size;
/* Warning: This loop has a very unusual condition and body.
* The loop needs to go through each page with at least one affected
@@ -1008,17 +1007,16 @@
* 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, int start, int len, int chunksize)
+int spi_write_chunked(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize)
{
int rc = 0;
- int i, j, starthere, lenhere;
+ unsigned int i, j, starthere, lenhere, towrite;
/* FIXME: page_size is the wrong variable. We need max_writechunk_size
* in struct flashchip to do this properly. All chips using
* spi_chip_write_256 have page_size set to max_writechunk_size, so
* we're OK for now.
*/
- int page_size = flash->page_size;
- int towrite;
+ unsigned int page_size = flash->page_size;
/* Warning: This loop has a very unusual condition and body.
* The loop needs to go through each page with at least one affected
@@ -1057,9 +1055,10 @@
* (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, int start, int len)
+int spi_chip_write_1(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
{
- int i, result = 0;
+ unsigned int i;
+ int result = 0;
for (i = start; i < start + len; i++) {
result = spi_byte_program(i, buf[i - start]);
@@ -1072,7 +1071,7 @@
return 0;
}
-int spi_aai_write(struct flashchip *flash, uint8_t *buf, int start, int len)
+int spi_aai_write(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
{
uint32_t pos = start;
int result;
diff --git a/sst28sf040.c b/sst28sf040.c
index d621cc7..2038d53 100644
--- a/sst28sf040.c
+++ b/sst28sf040.c
@@ -76,7 +76,7 @@
}
/* chunksize is 1 */
-int write_28sf040(struct flashchip *flash, uint8_t *src, int start, int len)
+int write_28sf040(struct flashchip *flash, uint8_t *src, unsigned int start, unsigned int len)
{
int i;
chipaddr bios = flash->virtual_memory;
diff --git a/sst49lfxxxc.c b/sst49lfxxxc.c
index 28f6cd0..c3ef823 100644
--- a/sst49lfxxxc.c
+++ b/sst49lfxxxc.c
@@ -35,7 +35,7 @@
static int write_lockbits_49lfxxxc(struct flashchip *flash, unsigned char bits)
{
chipaddr registers = flash->virtual_registers;
- int i, left = flash->total_size * 1024;
+ unsigned int i, left = flash->total_size * 1024;
unsigned long address;
msg_cdbg("\nbios=0x%08lx\n", registers);
diff --git a/w39.c b/w39.c
index 2e9aa4f..a2c1014 100644
--- a/w39.c
+++ b/w39.c
@@ -21,7 +21,7 @@
#include "flash.h"
-static int printlock_w39_fwh_block(struct flashchip *flash, int offset)
+static int printlock_w39_fwh_block(struct flashchip *flash, unsigned int offset)
{
chipaddr wrprotect = flash->virtual_registers + offset + 2;
uint8_t locking;
@@ -59,7 +59,7 @@
return (locking & ((1 << 2) | (1 << 0))) ? -1 : 0;
}
-static int unlock_w39_fwh_block(struct flashchip *flash, int offset)
+static int unlock_w39_fwh_block(struct flashchip *flash, unsigned int offset)
{
chipaddr wrprotect = flash->virtual_registers + offset + 2;
uint8_t locking;
@@ -80,7 +80,7 @@
return 0;
}
-static uint8_t w39_idmode_readb(struct flashchip *flash, int offset)
+static uint8_t w39_idmode_readb(struct flashchip *flash, unsigned int offset)
{
chipaddr bios = flash->virtual_memory;
uint8_t val;
@@ -127,7 +127,7 @@
return 0;
}
-static int printlock_w39_common(struct flashchip *flash, int offset)
+static int printlock_w39_common(struct flashchip *flash, unsigned int offset)
{
uint8_t lock;
@@ -138,7 +138,7 @@
static int printlock_w39_fwh(struct flashchip *flash)
{
- int i, total_size = flash->total_size * 1024;
+ unsigned int i, total_size = flash->total_size * 1024;
int ret = 0;
/* Print lock status of the complete chip */
@@ -150,7 +150,7 @@
static int unlock_w39_fwh(struct flashchip *flash)
{
- int i, total_size = flash->total_size * 1024;
+ unsigned int i, total_size = flash->total_size * 1024;
/* Unlock the complete chip */
for (i = 0; i < total_size; i += flash->page_size)
diff --git a/wbsio_spi.c b/wbsio_spi.c
index e76d09b..dbc7729 100644
--- a/wbsio_spi.c
+++ b/wbsio_spi.c
@@ -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, int start, int len);
+static int wbsio_spi_read(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned 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, int start, int len)
+static int wbsio_spi_read(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
{
return read_memmapped(flash, buf, start, len);
}