mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 07:02:34 +02:00
Fixup of r1397
- Mixing uninitialized and initialized local variables leads to confusion. - ft2232_spi error cases should have gotten some error handling, and that's the reason the curly braces were there. - Fixing typos/wording in some places would have been nice given that those places were touched anyway. Corresponding to flashrom svn r1413. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
This commit is contained in:
parent
0528b7fefa
commit
082c8b559c
@ -860,7 +860,7 @@ static int nvidia_mcp_gpio_set(int gpio, int raise)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* First, check the ISA bridge */
|
||||
/* Check for the ISA bridge first. */
|
||||
dev = pci_dev_find_vendorclass(0x10DE, 0x0601);
|
||||
switch (dev->device_id) {
|
||||
case 0x0030: /* CK804 */
|
||||
@ -1129,8 +1129,8 @@ static int intel_piix4_gpo_set(unsigned int gpo, int raise)
|
||||
struct pci_dev *dev;
|
||||
uint32_t tmp, base;
|
||||
|
||||
/* GPPO {0,8,27,28,30} are always available */
|
||||
static const uint32_t nonmuxed_gpos = 0x58000101;
|
||||
/* GPO{0,8,27,28,30} are always available. */
|
||||
static const uint32_t nonmuxed_gpos = 0x58000101;
|
||||
|
||||
static const struct {unsigned int reg, mask, value; } piix4_gpo[] = {
|
||||
{0},
|
||||
@ -1179,10 +1179,9 @@ static int intel_piix4_gpo_set(unsigned int gpo, int raise)
|
||||
}
|
||||
|
||||
if ((((1 << gpo) & nonmuxed_gpos) == 0) &&
|
||||
(pci_read_word(dev, piix4_gpo[gpo].reg)
|
||||
& piix4_gpo[gpo].mask) != piix4_gpo[gpo].value) {
|
||||
msg_perr("\nERROR: PIIX4 GPO%d not programmed for output.\n",
|
||||
gpo);
|
||||
((pci_read_word(dev, piix4_gpo[gpo].reg) & piix4_gpo[gpo].mask) !=
|
||||
piix4_gpo[gpo].value)) {
|
||||
msg_perr("\nERROR: PIIX4 GPO%d not programmed for output.\n", gpo);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -150,9 +150,11 @@ static int buspirate_spi_shutdown(void *data)
|
||||
int buspirate_spi_init(void)
|
||||
{
|
||||
unsigned char buf[512];
|
||||
int ret = 0, i, spispeed = 0x7;
|
||||
char *dev = NULL;
|
||||
char *speed = NULL;
|
||||
int spispeed = 0x7;
|
||||
int ret = 0;
|
||||
int i;
|
||||
|
||||
dev = extract_programmer_param("dev");
|
||||
if (!dev || !strlen(dev)) {
|
||||
|
@ -309,8 +309,9 @@ static int enable_flash_ich_4e(struct pci_dev *dev, const char *name)
|
||||
static int enable_flash_ich_dc(struct pci_dev *dev, const char *name)
|
||||
{
|
||||
uint32_t fwh_conf;
|
||||
int i, tmp;
|
||||
char *idsel = NULL;
|
||||
int i, tmp, max_decode_fwh_idsel = 0, max_decode_fwh_decode = 0;
|
||||
int max_decode_fwh_idsel = 0, max_decode_fwh_decode = 0;
|
||||
int contiguous = 1;
|
||||
|
||||
idsel = extract_programmer_param("fwh_idsel");
|
||||
@ -1035,7 +1036,7 @@ static int get_flashbase_sc520(struct pci_dev *dev, const char *name)
|
||||
}
|
||||
} else {
|
||||
msg_pinfo("AMD Elan SC520 detected, but no BOOTCS. "
|
||||
"Assuming flash at 4G\n");
|
||||
"Assuming flash at 4G.\n");
|
||||
}
|
||||
|
||||
/* 4. Clean up */
|
||||
|
@ -104,13 +104,14 @@ int cli_classic(int argc, char *argv[])
|
||||
struct flashchip flashes[3];
|
||||
struct flashchip *fill_flash;
|
||||
const char *name;
|
||||
int startchip = 0, chipcount = 0, namelen, opt, option_index = 0;
|
||||
int read_it = 0, write_it = 0, erase_it = 0, verify_it = 0;
|
||||
int dont_verify_it = 0, list_supported = 0, force = 0;
|
||||
int namelen, opt, i;
|
||||
int startchip = 0, chipcount = 0, option_index = 0, force = 0;
|
||||
#if CONFIG_PRINT_WIKI == 1
|
||||
int list_supported_wiki = 0;
|
||||
#endif
|
||||
int operation_specified = 0, i, ret = 0;
|
||||
int read_it = 0, write_it = 0, erase_it = 0, verify_it = 0;
|
||||
int dont_verify_it = 0, list_supported = 0, operation_specified = 0;
|
||||
int ret = 0;
|
||||
|
||||
static const char optstring[] = "r:Rw:v:nVEfc:m:l:i:p:Lzh";
|
||||
static const struct option long_options[] = {
|
||||
|
@ -496,7 +496,8 @@ static int dediprog_command_f(int timeout)
|
||||
static int parse_voltage(char *voltage)
|
||||
{
|
||||
char *tmp = NULL;
|
||||
int i, millivolt, fraction = 0;
|
||||
int i;
|
||||
int millivolt = 0, fraction = 0;
|
||||
|
||||
if (!voltage || !strlen(voltage)) {
|
||||
msg_perr("Empty voltage= specified.\n");
|
||||
@ -574,7 +575,8 @@ int dediprog_init(void)
|
||||
{
|
||||
struct usb_device *dev;
|
||||
char *voltage;
|
||||
int millivolt = 3500, ret;
|
||||
int millivolt = 3500;
|
||||
int ret;
|
||||
|
||||
msg_pspew("%s\n", __func__);
|
||||
|
||||
|
3
dmi.c
3
dmi.c
@ -196,7 +196,8 @@ void dmi_init(void)
|
||||
*/
|
||||
static int dmi_compare(const char *value, const char *pattern)
|
||||
{
|
||||
int anchored = 0, patternlen;
|
||||
int anchored = 0;
|
||||
int patternlen;
|
||||
|
||||
msg_pspew("matching %s against %s\n", value, pattern);
|
||||
/* The empty string is part of all strings! */
|
||||
|
22
flashrom.c
22
flashrom.c
@ -600,8 +600,7 @@ void map_flash_registers(struct flashchip *flash)
|
||||
size_t size = flash->total_size * 1024;
|
||||
/* Flash registers live 4 MByte below the flash. */
|
||||
/* FIXME: This is incorrect for nonstandard flashbase. */
|
||||
flash->virtual_registers = (chipaddr)programmer_map_flash_region(
|
||||
"flash chip registers", (0xFFFFFFFF - 0x400000 - size + 1), size);
|
||||
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)
|
||||
@ -753,8 +752,9 @@ int check_erased_range(struct flashchip *flash, int start, int len)
|
||||
int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len,
|
||||
const char *message)
|
||||
{
|
||||
int i, ret = 0, failcount = 0;
|
||||
int i;
|
||||
uint8_t *readbuf = malloc(len);
|
||||
int ret = 0, failcount = 0;
|
||||
|
||||
if (!len)
|
||||
goto out_free;
|
||||
@ -832,7 +832,8 @@ out_free:
|
||||
*/
|
||||
int need_erase(uint8_t *have, uint8_t *want, int len, enum write_granularity gran)
|
||||
{
|
||||
int result = 0, i, j, limit;
|
||||
int result = 0;
|
||||
int i, j, limit;
|
||||
|
||||
switch (gran) {
|
||||
case write_gran_1bit:
|
||||
@ -898,7 +899,8 @@ int need_erase(uint8_t *have, uint8_t *want, int len, enum write_granularity gra
|
||||
static int get_next_write(uint8_t *have, uint8_t *want, int len,
|
||||
int *first_start, enum write_granularity gran)
|
||||
{
|
||||
int need_write = 0, rel_start = 0, first_len = 0, i, limit, stride;
|
||||
int need_write = 0, rel_start = 0, first_len = 0;
|
||||
int i, limit, stride;
|
||||
|
||||
switch (gran) {
|
||||
case write_gran_1bit:
|
||||
@ -1326,7 +1328,8 @@ out_free:
|
||||
*/
|
||||
static int selfcheck_eraseblocks(const struct flashchip *flash)
|
||||
{
|
||||
int i, j, k, ret = 0;
|
||||
int i, j, k;
|
||||
int ret = 0;
|
||||
|
||||
for (k = 0; k < NUM_ERASEFUNCTIONS; k++) {
|
||||
unsigned int done = 0;
|
||||
@ -1451,7 +1454,8 @@ static int walk_eraseregions(struct flashchip *flash, int erasefunction,
|
||||
void *param1, void *param2)
|
||||
{
|
||||
int i, j;
|
||||
unsigned int start = 0, len;
|
||||
unsigned int start = 0;
|
||||
unsigned int len;
|
||||
struct block_eraser eraser = flash->block_erasers[erasefunction];
|
||||
|
||||
for (i = 0; i < NUM_ERASEREGIONS; i++) {
|
||||
@ -1603,8 +1607,10 @@ void list_programmers(const char *delim)
|
||||
void list_programmers_linebreak(int startcol, int cols, int paren)
|
||||
{
|
||||
const char *pname;
|
||||
int pnamelen, remaining = 0, firstline = 1, i;
|
||||
int pnamelen;
|
||||
int remaining = 0, firstline = 1;
|
||||
enum programmer p;
|
||||
int i;
|
||||
|
||||
for (p = 0; p < PROGRAMMER_INVALID; p++) {
|
||||
pname = programmer_table[p].name;
|
||||
|
15
ft2232_spi.c
15
ft2232_spi.c
@ -252,17 +252,21 @@ int ft2232_spi_init(void)
|
||||
ftdic->error_str);
|
||||
}
|
||||
|
||||
if (ftdi_usb_reset(ftdic) < 0)
|
||||
if (ftdi_usb_reset(ftdic) < 0) {
|
||||
msg_perr("Unable to reset FTDI device\n");
|
||||
}
|
||||
|
||||
if (ftdi_set_latency_timer(ftdic, 2) < 0)
|
||||
if (ftdi_set_latency_timer(ftdic, 2) < 0) {
|
||||
msg_perr("Unable to set latency timer\n");
|
||||
}
|
||||
|
||||
if (ftdi_write_data_set_chunksize(ftdic, 256))
|
||||
if (ftdi_write_data_set_chunksize(ftdic, 256)) {
|
||||
msg_perr("Unable to set chunk size\n");
|
||||
}
|
||||
|
||||
if (ftdi_set_bitmode(ftdic, 0x00, BITMODE_BITBANG_SPI) < 0)
|
||||
if (ftdi_set_bitmode(ftdic, 0x00, BITMODE_BITBANG_SPI) < 0) {
|
||||
msg_perr("Unable to set bitmode to SPI\n");
|
||||
}
|
||||
|
||||
if (clock_5x) {
|
||||
msg_pdbg("Disable divide-by-5 front stage\n");
|
||||
@ -329,7 +333,8 @@ static int ft2232_spi_send_command(unsigned int writecnt, unsigned int readcnt,
|
||||
struct ftdi_context *ftdic = &ftdic_context;
|
||||
static unsigned char *buf = NULL;
|
||||
/* failed is special. We use bitwise ops, but it is essentially bool. */
|
||||
int i = 0, ret = 0, failed = 0, bufsize;
|
||||
int i = 0, ret = 0, failed = 0;
|
||||
int bufsize;
|
||||
static int oldbufsize = 0;
|
||||
|
||||
if (writecnt > 65536 || readcnt > 65536)
|
||||
|
17
it85spi.c
17
it85spi.c
@ -84,15 +84,15 @@ unsigned char *ce_high, *ce_low;
|
||||
static int it85xx_scratch_rom_reenter = 0;
|
||||
|
||||
/* This function will poll the keyboard status register until either
|
||||
* an expected value shows up, or
|
||||
* timeout reaches.
|
||||
* an expected value shows up, or the timeout is reached.
|
||||
* timeout is in usec.
|
||||
*
|
||||
* Returns: 0 -- the expected value has shown.
|
||||
* 1 -- timeout reached.
|
||||
* Returns: 0 -- the expected value showed up.
|
||||
* 1 -- timeout.
|
||||
*/
|
||||
static int wait_for(const unsigned int mask, const unsigned int expected_value,
|
||||
const int timeout /* in usec */, const char *error_message,
|
||||
const char *function_name, const int lineno)
|
||||
const int timeout, const char * error_message,
|
||||
const char * function_name, const int lineno)
|
||||
{
|
||||
int time_passed;
|
||||
|
||||
@ -317,8 +317,9 @@ static int it85xx_spi_send_command(unsigned int writecnt, unsigned int readcnt,
|
||||
int i;
|
||||
|
||||
it85xx_enter_scratch_rom();
|
||||
/* exit scratch ROM ONLY when programmer shuts down. Otherwise, the
|
||||
* temporary flash state may halt EC. */
|
||||
/* Exit scratch ROM ONLY when programmer shuts down. Otherwise, the
|
||||
* temporary flash state may halt the EC.
|
||||
*/
|
||||
|
||||
#ifdef LPC_IO
|
||||
INDIRECT_A1(shm_io_base, (((unsigned long int)ce_high) >> 8) & 0xff);
|
||||
|
@ -203,7 +203,8 @@ static uint16_t it87spi_probe(uint16_t port)
|
||||
|
||||
int init_superio_ite(void)
|
||||
{
|
||||
int i, ret = 0;
|
||||
int i;
|
||||
int ret = 0;
|
||||
|
||||
for (i = 0; i < superio_count; i++) {
|
||||
if (superios[i].vendor != SUPERIO_VENDOR_ITE)
|
||||
|
Loading…
x
Reference in New Issue
Block a user