Skip to content

Commit

Permalink
hw/block/nand: Have blk_load() take unsigned offset and return boolean
Browse files Browse the repository at this point in the history
Negative offset is meaningless, use unsigned type.
Return a boolean value indicating success.

Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <[email protected]>
(cherry picked from commit 2e3e09b)
Signed-off-by: Michael Tokarev <[email protected]>
  • Loading branch information
philmd authored and Michael Tokarev committed Apr 10, 2024
1 parent 15b4146 commit ab99589
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions hw/block/nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ struct NANDFlashState {

void (*blk_write)(NANDFlashState *s);
void (*blk_erase)(NANDFlashState *s);
void (*blk_load)(NANDFlashState *s, uint64_t addr, int offset);
/*
* Returns %true when block containing (@addr + @offset) is
* successfully loaded, otherwise %false.
*/
bool (*blk_load)(NANDFlashState *s, uint64_t addr, unsigned offset);

uint32_t ioaddr_vmstate;
};
Expand Down Expand Up @@ -772,11 +776,11 @@ static void glue(nand_blk_erase_, NAND_PAGE_SIZE)(NANDFlashState *s)
}
}

static void glue(nand_blk_load_, NAND_PAGE_SIZE)(NANDFlashState *s,
uint64_t addr, int offset)
static bool glue(nand_blk_load_, NAND_PAGE_SIZE)(NANDFlashState *s,
uint64_t addr, unsigned offset)
{
if (PAGE(addr) >= s->pages) {
return;
return false;
}

if (s->blk) {
Expand Down Expand Up @@ -804,6 +808,8 @@ static void glue(nand_blk_load_, NAND_PAGE_SIZE)(NANDFlashState *s,
offset, NAND_PAGE_SIZE + OOB_SIZE - offset);
s->ioaddr = s->io;
}

return true;
}

static void glue(nand_init_, NAND_PAGE_SIZE)(NANDFlashState *s)
Expand Down

0 comments on commit ab99589

Please sign in to comment.