forked from luck/tmp_suning_uos_patched
mtd: spi-nor: sfdp: add/use local variable in spi_nor_parse_bfpt()
Despite of how spi_nor_parse_bfpt() abuses the structure fields during their calculation, gcc manages to make some decent code out of that. :-) Yet adding a local variable to store the BFPT DWORDs during calculations still saves 12 bytes of the object code (AArch64 gcc 4.8.5)... Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
This commit is contained in:
parent
dec18bd8f4
commit
0fa712c9db
|
@ -437,7 +437,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
|
|||
struct sfdp_bfpt bfpt;
|
||||
size_t len;
|
||||
int i, cmd, err;
|
||||
u32 addr;
|
||||
u32 addr, val;
|
||||
u16 half;
|
||||
u8 erase_mask;
|
||||
|
||||
|
@ -473,21 +473,21 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
|
|||
}
|
||||
|
||||
/* Flash Memory Density (in bits). */
|
||||
params->size = bfpt.dwords[BFPT_DWORD(2)];
|
||||
if (params->size & BIT(31)) {
|
||||
params->size &= ~BIT(31);
|
||||
val = bfpt.dwords[BFPT_DWORD(2)];
|
||||
if (val & BIT(31)) {
|
||||
val &= ~BIT(31);
|
||||
|
||||
/*
|
||||
* Prevent overflows on params->size. Anyway, a NOR of 2^64
|
||||
* bits is unlikely to exist so this error probably means
|
||||
* the BFPT we are reading is corrupted/wrong.
|
||||
*/
|
||||
if (params->size > 63)
|
||||
if (val > 63)
|
||||
return -EINVAL;
|
||||
|
||||
params->size = 1ULL << params->size;
|
||||
params->size = 1ULL << val;
|
||||
} else {
|
||||
params->size++;
|
||||
params->size = val + 1;
|
||||
}
|
||||
params->size >>= 3; /* Convert to bytes. */
|
||||
|
||||
|
@ -554,10 +554,10 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
|
|||
params);
|
||||
|
||||
/* Page size: this field specifies 'N' so the page size = 2^N bytes. */
|
||||
params->page_size = bfpt.dwords[BFPT_DWORD(11)];
|
||||
params->page_size &= BFPT_DWORD11_PAGE_SIZE_MASK;
|
||||
params->page_size >>= BFPT_DWORD11_PAGE_SIZE_SHIFT;
|
||||
params->page_size = 1U << params->page_size;
|
||||
val = bfpt.dwords[BFPT_DWORD(11)];
|
||||
val &= BFPT_DWORD11_PAGE_SIZE_MASK;
|
||||
val >>= BFPT_DWORD11_PAGE_SIZE_SHIFT;
|
||||
params->page_size = 1U << val;
|
||||
|
||||
/* Quad Enable Requirements. */
|
||||
switch (bfpt.dwords[BFPT_DWORD(15)] & BFPT_DWORD15_QER_MASK) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user