drivers: flash: Fix union shadowing warning

Because shadow variable warning is turned on, a warning was thrown and
could fail some twister tests that don't use the -W option. This commit
gets rid of the warning.

Signed-off-by: David Corbeil <david.corbeil@dynon.com>
This commit is contained in:
David Corbeil 2023-10-03 12:51:20 -04:00 committed by Carles Cufí
parent 6b60dc4e0d
commit 0f5c6b7d74

View file

@ -1029,10 +1029,10 @@ static int spi_nor_process_sfdp(const struct device *dev)
/* We only process BFP so use one parameter block */ /* We only process BFP so use one parameter block */
uint8_t raw[JESD216_SFDP_SIZE(decl_nph)]; uint8_t raw[JESD216_SFDP_SIZE(decl_nph)];
struct jesd216_sfdp_header sfdp; struct jesd216_sfdp_header sfdp;
} u; } u_header;
const struct jesd216_sfdp_header *hp = &u.sfdp; const struct jesd216_sfdp_header *hp = &u_header.sfdp;
rc = spi_nor_sfdp_read(dev, 0, u.raw, sizeof(u.raw)); rc = spi_nor_sfdp_read(dev, 0, u_header.raw, sizeof(u_header.raw));
if (rc != 0) { if (rc != 0) {
LOG_ERR("SFDP read failed: %d", rc); LOG_ERR("SFDP read failed: %d", rc);
return rc; return rc;
@ -1062,10 +1062,11 @@ static int spi_nor_process_sfdp(const struct device *dev)
union { union {
uint32_t dw[MIN(php->len_dw, 20)]; uint32_t dw[MIN(php->len_dw, 20)];
struct jesd216_bfp bfp; struct jesd216_bfp bfp;
} u; } u_param;
const struct jesd216_bfp *bfp = &u.bfp; const struct jesd216_bfp *bfp = &u_param.bfp;
rc = spi_nor_sfdp_read(dev, jesd216_param_addr(php), u.dw, sizeof(u.dw)); rc = spi_nor_sfdp_read(dev, jesd216_param_addr(php),
u_param.dw, sizeof(u_param.dw));
if (rc == 0) { if (rc == 0) {
rc = spi_nor_process_bfp(dev, php, bfp); rc = spi_nor_process_bfp(dev, php, bfp);
} }