summaryrefslogtreecommitdiffstats
path: root/spi25.c
diff options
context:
space:
mode:
authorMathias Krause <mathias.krause@secunet.com>2011-01-17 07:50:42 +0000
committerMathias Krause <mathias.krause@secunet.com>2011-01-17 07:50:42 +0000
commita60faab83ef86bcf2884311db07cf13f445d7f47 (patch)
tree9de9787987eb6a3374e18835b196b7ac6cb9ad19 /spi25.c
parent2c3afa34fcfc72abe6b3e0fd034632226fa75522 (diff)
downloadast2050-flashrom-a60faab83ef86bcf2884311db07cf13f445d7f47.zip
ast2050-flashrom-a60faab83ef86bcf2884311db07cf13f445d7f47.tar.gz
Convince compilers to put constant data into the .rodata section
This patch reduces the stack usage by declaring 'const' stack variables as 'static const' so they end up in the .rodata section instead of being copied from there to the stack for every invocation of the corresponding function. As a plus we end up in having a smaller binary as the "copy from .rodata to stack" code isn't emitted by the compiler any more (roughly -100 bytes). Corresponding to flashrom svn r1252. Signed-off-by: Mathias Krause <mathias.krause@secunet.com> Acked-by: Stefan Reinauer <stepan@coreboot.org>
Diffstat (limited to 'spi25.c')
-rw-r--r--spi25.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/spi25.c b/spi25.c
index fc3173f..c9e1ebf 100644
--- a/spi25.c
+++ b/spi25.c
@@ -33,7 +33,7 @@ void spi_prettyprint_status_register(struct flashchip *flash);
static int spi_rdid(unsigned char *readarr, int bytes)
{
- const unsigned char cmd[JEDEC_RDID_OUTSIZE] = { JEDEC_RDID };
+ static const unsigned char cmd[JEDEC_RDID_OUTSIZE] = { JEDEC_RDID };
int ret;
int i;
@@ -95,7 +95,7 @@ static int spi_res(unsigned char *readarr, int bytes)
int spi_write_enable(void)
{
- const unsigned char cmd[JEDEC_WREN_OUTSIZE] = { JEDEC_WREN };
+ static const unsigned char cmd[JEDEC_WREN_OUTSIZE] = { JEDEC_WREN };
int result;
/* Send WREN (Write Enable) */
@@ -109,7 +109,7 @@ int spi_write_enable(void)
int spi_write_disable(void)
{
- const unsigned char cmd[JEDEC_WRDI_OUTSIZE] = { JEDEC_WRDI };
+ static const unsigned char cmd[JEDEC_WRDI_OUTSIZE] = { JEDEC_WRDI };
/* Send WRDI (Write Disable) */
return spi_send_command(sizeof(cmd), 0, cmd, NULL);
@@ -232,10 +232,10 @@ int probe_spi_rems(struct flashchip *flash)
int probe_spi_res1(struct flashchip *flash)
{
+ static const unsigned char allff[] = {0xff, 0xff, 0xff};
+ static const unsigned char all00[] = {0x00, 0x00, 0x00};
unsigned char readarr[3];
uint32_t id2;
- const unsigned char allff[] = {0xff, 0xff, 0xff};
- const unsigned char all00[] = {0x00, 0x00, 0x00};
/* We only want one-byte RES if RDID and REMS are unusable. */
@@ -298,7 +298,7 @@ int probe_spi_res2(struct flashchip *flash)
uint8_t spi_read_status_register(void)
{
- const unsigned char cmd[JEDEC_RDSR_OUTSIZE] = { JEDEC_RDSR };
+ static const unsigned char cmd[JEDEC_RDSR_OUTSIZE] = { JEDEC_RDSR };
/* FIXME: No workarounds for driver/hardware bugs in generic code. */
unsigned char readarr[2]; /* JEDEC_RDSR_INSIZE=1 but wbsio needs 2 */
int ret;
@@ -486,7 +486,7 @@ void spi_prettyprint_status_register_sst25(uint8_t status)
*/
void spi_prettyprint_status_register_sst25vf016(uint8_t status)
{
- const char *bpt[] = {
+ static const char *const bpt[] = {
"none",
"1F0000H-1FFFFFH",
"1E0000H-1FFFFFH",
@@ -502,7 +502,7 @@ void spi_prettyprint_status_register_sst25vf016(uint8_t status)
void spi_prettyprint_status_register_sst25vf040b(uint8_t status)
{
- const char *bpt[] = {
+ static const char *const bpt[] = {
"none",
"0x70000-0x7ffff",
"0x60000-0x7ffff",
@@ -837,7 +837,7 @@ int spi_block_erase_c7(struct flashchip *flash, unsigned int addr, unsigned int
int spi_write_status_enable(void)
{
- const unsigned char cmd[JEDEC_EWSR_OUTSIZE] = { JEDEC_EWSR };
+ static const unsigned char cmd[JEDEC_EWSR_OUTSIZE] = { JEDEC_EWSR };
int result;
/* Send EWSR (Enable Write Status Register). */
OpenPOWER on IntegriCloud