From d541a3a1919f90b8b6dc8e649d586df7e407cb54 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Fri, 4 Mar 2022 13:18:46 +0000 Subject: [PATCH] x1000: fix nand driver reference counting Somehow I screwed this up as well. Seems it didn't cause trouble. Change-Id: I5ab99dd9182a4e60d55984fecbf20ca823dbd004 --- firmware/target/mips/ingenic_x1000/nand-x1000.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/firmware/target/mips/ingenic_x1000/nand-x1000.c b/firmware/target/mips/ingenic_x1000/nand-x1000.c index 67f1aead45..46187da9b9 100644 --- a/firmware/target/mips/ingenic_x1000/nand-x1000.c +++ b/firmware/target/mips/ingenic_x1000/nand-x1000.c @@ -190,8 +190,10 @@ static void setup_chip_registers(nand_drv* drv) int nand_open(nand_drv* drv) { - if(drv->refcount > 0) + if(drv->refcount > 0) { + drv->refcount++; return NAND_SUCCESS; + } /* Initialize the controller */ sfc_open(); @@ -222,7 +224,8 @@ int nand_open(nand_drv* drv) void nand_close(nand_drv* drv) { - if(drv->refcount == 0) + --drv->refcount; + if(drv->refcount > 0) return; /* Let's reset the chip... the idea is to restore the registers @@ -231,7 +234,6 @@ void nand_close(nand_drv* drv) mdelay(10); sfc_close(); - drv->refcount--; } static uint8_t nand_wait_busy(nand_drv* drv)