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:
Sergei Shtylyov 2020-04-22 22:00:18 +03:00 коммит произвёл Tudor Ambarus
Родитель dec18bd8f4
Коммит 0fa712c9db
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4B554F47A58D14E9
1 изменённых файлов: 11 добавлений и 11 удалений

Просмотреть файл

@ -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) {