summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-03-04 13:18:46 +0000
committerAidan MacDonald <amachronic@protonmail.com>2022-03-04 08:57:35 -0500
commitd541a3a1919f90b8b6dc8e649d586df7e407cb54 (patch)
treecaefa57754f12df056b15d0b6f27908542db0872 /firmware
parent3cb7167e2206fa39d9fc20920727f4b858f0dac6 (diff)
downloadrockbox-d541a3a1919f90b8b6dc8e649d586df7e407cb54.tar.gz
rockbox-d541a3a1919f90b8b6dc8e649d586df7e407cb54.zip
x1000: fix nand driver reference counting
Somehow I screwed this up as well. Seems it didn't cause trouble. Change-Id: I5ab99dd9182a4e60d55984fecbf20ca823dbd004
Diffstat (limited to 'firmware')
-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)