Skip to content

Commit 2e3e09b

Browse files
committed
hw/block/nand: Have blk_load() take unsigned offset and return boolean
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]>
1 parent 7a86544 commit 2e3e09b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

hw/block/nand.c

+10-4
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ struct NANDFlashState {
8484

8585
void (*blk_write)(NANDFlashState *s);
8686
void (*blk_erase)(NANDFlashState *s);
87-
void (*blk_load)(NANDFlashState *s, uint64_t addr, int offset);
87+
/*
88+
* Returns %true when block containing (@addr + @offset) is
89+
* successfully loaded, otherwise %false.
90+
*/
91+
bool (*blk_load)(NANDFlashState *s, uint64_t addr, unsigned offset);
8892

8993
uint32_t ioaddr_vmstate;
9094
};
@@ -772,11 +776,11 @@ static void glue(nand_blk_erase_, NAND_PAGE_SIZE)(NANDFlashState *s)
772776
}
773777
}
774778

775-
static void glue(nand_blk_load_, NAND_PAGE_SIZE)(NANDFlashState *s,
776-
uint64_t addr, int offset)
779+
static bool glue(nand_blk_load_, NAND_PAGE_SIZE)(NANDFlashState *s,
780+
uint64_t addr, unsigned offset)
777781
{
778782
if (PAGE(addr) >= s->pages) {
779-
return;
783+
return false;
780784
}
781785

782786
if (s->blk) {
@@ -804,6 +808,8 @@ static void glue(nand_blk_load_, NAND_PAGE_SIZE)(NANDFlashState *s,
804808
offset, NAND_PAGE_SIZE + OOB_SIZE - offset);
805809
s->ioaddr = s->io;
806810
}
811+
812+
return true;
807813
}
808814

809815
static void glue(nand_init_, NAND_PAGE_SIZE)(NANDFlashState *s)

0 commit comments

Comments
 (0)