summaryrefslogtreecommitdiff
path: root/firmware/target
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/mips/ingenic_x1000/nand-x1000.c8
1 files 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)
190 190
191int nand_open(nand_drv* drv) 191int nand_open(nand_drv* drv)
192{ 192{
193 if(drv->refcount > 0) 193 if(drv->refcount > 0) {
194 drv->refcount++;
194 return NAND_SUCCESS; 195 return NAND_SUCCESS;
196 }
195 197
196 /* Initialize the controller */ 198 /* Initialize the controller */
197 sfc_open(); 199 sfc_open();
@@ -222,7 +224,8 @@ int nand_open(nand_drv* drv)
222 224
223void nand_close(nand_drv* drv) 225void nand_close(nand_drv* drv)
224{ 226{
225 if(drv->refcount == 0) 227 --drv->refcount;
228 if(drv->refcount > 0)
226 return; 229 return;
227 230
228 /* Let's reset the chip... the idea is to restore the registers 231 /* Let's reset the chip... the idea is to restore the registers
@@ -231,7 +234,6 @@ void nand_close(nand_drv* drv)
231 mdelay(10); 234 mdelay(10);
232 235
233 sfc_close(); 236 sfc_close();
234 drv->refcount--;
235} 237}
236 238
237static uint8_t nand_wait_busy(nand_drv* drv) 239static uint8_t nand_wait_busy(nand_drv* drv)