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)