Skip to content

Commit 3fcbb8f

Browse files
authored
Merge pull request #958 from PS2HomeDeveloper/recover-pr-936
mx4sio: resume partial transfers at the next sector
2 parents 87e6ae9 + a67be52 commit 3fcbb8f

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎iop/sio/mx4sio_bd/src/spi_sdcard_driver.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@ int spisd_read(struct block_device *bd, uint64_t sector, void *buffer, uint16_t
624624
/* fail condition */
625625
if (sectors_left > 0) {
626626
buffer = (uint8_t *)buffer + (results * 512);
627+
sector += results;
627628
M_DEBUG("ERROR: failed to read all sectors, read:%i, abort:%i\n", sectors_left, cmd.abort);
628629

629630
if (cmd.abort == CMD_ABORT_NO_READ_TOKEN) {
@@ -681,7 +682,7 @@ int spisd_write(struct block_device *bd, uint64_t sector, const void *buffer, ui
681682
while (sectors_left > 0 && retries < MAX_RETRIES) {
682683

683684
/* issue CMD25 to begin transfer */
684-
results = spisd_write_multi_begin(sector, count);
685+
results = spisd_write_multi_begin((uint32_t)sector, sectors_left);
685686
if (results != SPISD_RESULT_OK) {
686687
M_DEBUG("ERROR: failed to start multi-block write\n");
687688
break;
@@ -694,6 +695,7 @@ int spisd_write(struct block_device *bd, uint64_t sector, const void *buffer, ui
694695
/* fail condition */
695696
if (sectors_left > 0) {
696697
write_buffer = (uint8_t *)write_buffer + (results * 512); /* update buffer for next attempt */
698+
sector += results;
697699
M_DEBUG("ERROR: failed to write all sectors, wrote: %i\n", results);
698700
}
699701

@@ -724,4 +726,4 @@ int spisd_stop(struct block_device *bd)
724726
{
725727
(void)bd;
726728
return 0;
727-
}
729+
}

0 commit comments

Comments
 (0)