mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 23:22:37 +02:00
Fix all remaining issues reported by LLVM/clang's scan-build
Corresponding to flashrom svn r723. Signed-off-by: Stefan Reinauer <stepan@coresystems.de> Acked-by: Ronald G. Minnich <rminnich@gmail.com>
This commit is contained in:
parent
9e72aa51a7
commit
ab044b20a2
23
82802ab.c
23
82802ab.c
@ -33,13 +33,13 @@
|
|||||||
// I need that Berkeley bit-map printer
|
// I need that Berkeley bit-map printer
|
||||||
void print_82802ab_status(uint8_t status)
|
void print_82802ab_status(uint8_t status)
|
||||||
{
|
{
|
||||||
printf("%s", status & 0x80 ? "Ready:" : "Busy:");
|
printf_debug("%s", status & 0x80 ? "Ready:" : "Busy:");
|
||||||
printf("%s", status & 0x40 ? "BE SUSPEND:" : "BE RUN/FINISH:");
|
printf_debug("%s", status & 0x40 ? "BE SUSPEND:" : "BE RUN/FINISH:");
|
||||||
printf("%s", status & 0x20 ? "BE ERROR:" : "BE OK:");
|
printf_debug("%s", status & 0x20 ? "BE ERROR:" : "BE OK:");
|
||||||
printf("%s", status & 0x10 ? "PROG ERR:" : "PROG OK:");
|
printf_debug("%s", status & 0x10 ? "PROG ERR:" : "PROG OK:");
|
||||||
printf("%s", status & 0x8 ? "VP ERR:" : "VPP OK:");
|
printf_debug("%s", status & 0x8 ? "VP ERR:" : "VPP OK:");
|
||||||
printf("%s", status & 0x4 ? "PROG SUSPEND:" : "PROG RUN/FINISH:");
|
printf_debug("%s", status & 0x4 ? "PROG SUSPEND:" : "PROG RUN/FINISH:");
|
||||||
printf("%s", status & 0x2 ? "WP|TBL#|WP#,ABORT:" : "UNLOCK:");
|
printf_debug("%s", status & 0x2 ? "WP|TBL#|WP#,ABORT:" : "UNLOCK:");
|
||||||
}
|
}
|
||||||
|
|
||||||
int probe_82802ab(struct flashchip *flash)
|
int probe_82802ab(struct flashchip *flash)
|
||||||
@ -98,20 +98,19 @@ int erase_82802ab_block(struct flashchip *flash, int offset)
|
|||||||
|
|
||||||
// clear status register
|
// clear status register
|
||||||
chip_writeb(0x50, bios);
|
chip_writeb(0x50, bios);
|
||||||
//printf("Erase at %p\n", bios);
|
|
||||||
// clear write protect
|
// clear write protect
|
||||||
//printf("write protect is at %p\n", (wrprotect));
|
|
||||||
//printf("write protect is 0x%x\n", *(wrprotect));
|
|
||||||
chip_writeb(0, wrprotect);
|
chip_writeb(0, wrprotect);
|
||||||
//printf("write protect is 0x%x\n", *(wrprotect));
|
|
||||||
|
|
||||||
// now start it
|
// now start it
|
||||||
chip_writeb(0x20, bios);
|
chip_writeb(0x20, bios);
|
||||||
chip_writeb(0xd0, bios);
|
chip_writeb(0xd0, bios);
|
||||||
programmer_delay(10);
|
programmer_delay(10);
|
||||||
|
|
||||||
// now let's see what the register is
|
// now let's see what the register is
|
||||||
status = wait_82802ab(flash->virtual_memory);
|
status = wait_82802ab(flash->virtual_memory);
|
||||||
//print_82802ab_status(status);
|
print_82802ab_status(status);
|
||||||
|
|
||||||
if (check_erased_range(flash, offset, flash->page_size)) {
|
if (check_erased_range(flash, offset, flash->page_size)) {
|
||||||
fprintf(stderr, "ERASE FAILED!\n");
|
fprintf(stderr, "ERASE FAILED!\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
27
ft2232_spi.c
27
ft2232_spi.c
@ -70,7 +70,6 @@ int ft2232_spi_init(void)
|
|||||||
int f;
|
int f;
|
||||||
struct ftdi_context *ftdic = &ftdic_context;
|
struct ftdi_context *ftdic = &ftdic_context;
|
||||||
unsigned char buf[512];
|
unsigned char buf[512];
|
||||||
unsigned char port_val = 0;
|
|
||||||
char *portpos = NULL;
|
char *portpos = NULL;
|
||||||
int ft2232_type = FTDI_FT4232H;
|
int ft2232_type = FTDI_FT4232H;
|
||||||
enum ftdi_interface ft2232_interface = INTERFACE_B;
|
enum ftdi_interface ft2232_interface = INTERFACE_B;
|
||||||
@ -175,9 +174,8 @@ int ft2232_spi_init(void)
|
|||||||
* dir: 0x0b CS=output, DI=input, DO=output, SK=output
|
* dir: 0x0b CS=output, DI=input, DO=output, SK=output
|
||||||
*/
|
*/
|
||||||
#define CS_BIT 0x08
|
#define CS_BIT 0x08
|
||||||
|
|
||||||
buf[0] = SET_BITS_LOW;
|
buf[0] = SET_BITS_LOW;
|
||||||
buf[1] = (port_val = CS_BIT);
|
buf[1] = CS_BIT;
|
||||||
buf[2] = 0x0b;
|
buf[2] = 0x0b;
|
||||||
if (send_buf(ftdic, buf, 3))
|
if (send_buf(ftdic, buf, 3))
|
||||||
return -1;
|
return -1;
|
||||||
@ -195,7 +193,6 @@ int ft2232_spi_send_command(unsigned int writecnt, unsigned int readcnt,
|
|||||||
{
|
{
|
||||||
struct ftdi_context *ftdic = &ftdic_context;
|
struct ftdi_context *ftdic = &ftdic_context;
|
||||||
static unsigned char *buf = NULL;
|
static unsigned char *buf = NULL;
|
||||||
unsigned char port_val = 0;
|
|
||||||
int i, ret = 0;
|
int i, ret = 0;
|
||||||
|
|
||||||
if (writecnt > 65536 || readcnt > 65536)
|
if (writecnt > 65536 || readcnt > 65536)
|
||||||
@ -213,10 +210,11 @@ int ft2232_spi_send_command(unsigned int writecnt, unsigned int readcnt,
|
|||||||
* as possible together. if we're not expecting to
|
* as possible together. if we're not expecting to
|
||||||
* read, we can assert CS, write, and deassert CS all
|
* read, we can assert CS, write, and deassert CS all
|
||||||
* in one shot. if reading, we do three separate
|
* in one shot. if reading, we do three separate
|
||||||
* operations. */
|
* operations.
|
||||||
|
*/
|
||||||
printf_debug("Assert CS#\n");
|
printf_debug("Assert CS#\n");
|
||||||
buf[i++] = SET_BITS_LOW;
|
buf[i++] = SET_BITS_LOW;
|
||||||
buf[i++] = (port_val &= ~CS_BIT);
|
buf[i++] = 0 & ~CS_BIT; /* assertive */
|
||||||
buf[i++] = 0x0b;
|
buf[i++] = 0x0b;
|
||||||
|
|
||||||
if (writecnt) {
|
if (writecnt) {
|
||||||
@ -236,20 +234,19 @@ int ft2232_spi_send_command(unsigned int writecnt, unsigned int readcnt,
|
|||||||
buf[i++] = ((readcnt - 1) >> 8) & 0xff;
|
buf[i++] = ((readcnt - 1) >> 8) & 0xff;
|
||||||
ret = send_buf(ftdic, buf, i);
|
ret = send_buf(ftdic, buf, i);
|
||||||
i = 0;
|
i = 0;
|
||||||
if (ret) goto deassert_cs;
|
if (ret == 0) {
|
||||||
|
/* FIXME: This is unreliable. There's no guarantee that we read
|
||||||
/* FIXME: This is unreliable. There's no guarantee that we read
|
* the response directly after sending the read command.
|
||||||
* the response directly after sending the read command.
|
* We may be scheduled out etc.
|
||||||
* We may be scheduled out etc.
|
*/
|
||||||
*/
|
ret = get_buf(ftdic, readarr, readcnt);
|
||||||
ret = get_buf(ftdic, readarr, readcnt);
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deassert_cs:
|
|
||||||
printf_debug("De-assert CS#\n");
|
printf_debug("De-assert CS#\n");
|
||||||
buf[i++] = SET_BITS_LOW;
|
buf[i++] = SET_BITS_LOW;
|
||||||
buf[i++] = (port_val |= CS_BIT);
|
buf[i++] = CS_BIT;
|
||||||
buf[i++] = 0x0b;
|
buf[i++] = 0x0b;
|
||||||
if (send_buf(ftdic, buf, i))
|
if (send_buf(ftdic, buf, i))
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -64,6 +64,11 @@ int sb600_spi_write_1(struct flashchip *flash, uint8_t *buf)
|
|||||||
printf("Programming flash");
|
printf("Programming flash");
|
||||||
for (i = 0; i < total_size; i++, buf++) {
|
for (i = 0; i < total_size; i++, buf++) {
|
||||||
result = spi_byte_program(i, *buf);
|
result = spi_byte_program(i, *buf);
|
||||||
|
if (result) {
|
||||||
|
// spi_byte_program reported the error for us already
|
||||||
|
printf_debug("... continuing anyway.\n");
|
||||||
|
}
|
||||||
|
|
||||||
/* wait program complete. */
|
/* wait program complete. */
|
||||||
if (i % 0x8000 == 0)
|
if (i % 0x8000 == 0)
|
||||||
printf(".");
|
printf(".");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user