Skip to content

Commit

Permalink
check status only on read and writes
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-hofmeier committed Nov 17, 2023
1 parent 6d12fff commit 21bee9a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
6 changes: 6 additions & 0 deletions source/mlc.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,9 @@ int mlc_end_read(struct sdmmc_command* cmdbuf)
if (cmdbuf->c_error) {
printf("mlc: MMC_READ_BLOCK_%s failed with %d\n", cmdbuf->c_opcode == MMC_READ_BLOCK_MULTIPLE ? "MULTIPLE" : "SINGLE", cmdbuf->c_error);
return -1;
} else if(ISSET(cmdbuf->c_flags, SCF_RSP_R1) && (MMC_R1(cmdbuf->c_resp) & MMC_R1_ANY_ERROR)){
printf("mlc: reported read error. status: %08lx\n", MMC_R1(cmdbuf->c_resp));
return -2;
}
if(cmdbuf->c_opcode == MMC_READ_BLOCK_MULTIPLE)
DPRINTF(2, ("mlc: async MMC_READ_BLOCK_MULTIPLE finished\n"));
Expand Down Expand Up @@ -860,6 +863,9 @@ int mlc_end_write(struct sdmmc_command* cmdbuf)
if (cmdbuf->c_error) {
printf("mlc: MMC_WRITE_BLOCK_%s failed with %d\n", cmdbuf->c_opcode == MMC_WRITE_BLOCK_MULTIPLE ? "MULTIPLE" : "SINGLE", cmdbuf->c_error);
return -1;
} else if(ISSET(cmdbuf->c_flags, SCF_RSP_R1) && (MMC_R1(cmdbuf->c_resp) & MMC_R1_ANY_ERROR)){
printf("mlc: reported write error. status: %08lx\n", MMC_R1(cmdbuf->c_resp));
return -2;
}
if(cmdbuf->c_opcode == MMC_WRITE_BLOCK_MULTIPLE)
DPRINTF(2, ("mlc: async MMC_WRITE_BLOCK_MULTIPLE finished\n"));
Expand Down
12 changes: 12 additions & 0 deletions source/sdcard.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,9 @@ int sdcard_end_read(struct sdmmc_command* cmdbuf)
if (cmdbuf->c_error) {
printf("sdcard: MMC_READ_BLOCK_%s failed with %d\n", cmdbuf->c_opcode == MMC_READ_BLOCK_MULTIPLE ? "MULTIPLE" : "SINGLE", cmdbuf->c_error);
return -1;
} else if(ISSET(cmdbuf->c_flags, SCF_RSP_R1) && (MMC_R1(cmdbuf->c_resp) & MMC_R1_ANY_ERROR)){
printf("sdcard: read reported error. status: %08lx\n", MMC_R1(cmdbuf->c_resp));
return -2;
}
if(cmdbuf->c_opcode == MMC_READ_BLOCK_MULTIPLE)
DPRINTF(2, ("sdcard: async MMC_READ_BLOCK_MULTIPLE finished\n"));
Expand Down Expand Up @@ -624,6 +627,9 @@ int sdcard_read(u32 blk_start, u32 blk_count, void *data)
goto retry_single;
}
return -1;
} else if(ISSET(cmd.c_flags, SCF_RSP_R1) && (MMC_R1(cmd.c_resp) & MMC_R1_ANY_ERROR)){
printf("sdcard: read reported error. status: %08lx\n", MMC_R1(cmd.c_resp));
return -2;
}
if(blk_count > 1)
DPRINTF(2, ("sdcard: MMC_READ_BLOCK_MULTIPLE done\n"));
Expand Down Expand Up @@ -708,6 +714,9 @@ int sdcard_end_write(struct sdmmc_command* cmdbuf)
if (cmdbuf->c_error) {
printf("sdcard: MMC_WRITE_BLOCK_%s failed with %d\n", cmdbuf->c_opcode == MMC_WRITE_BLOCK_MULTIPLE ? "MULTIPLE" : "SINGLE", cmdbuf->c_error);
return -1;
} else if(ISSET(cmdbuf->c_flags, SCF_RSP_R1) && (MMC_R1(cmdbuf->c_resp) & MMC_R1_ANY_ERROR)){
printf("sdcard: write reported error. status: %08lx\n", MMC_R1(cmdbuf->c_resp));
return -2;
}
if(cmdbuf->c_opcode == MMC_WRITE_BLOCK_MULTIPLE)
DPRINTF(2, ("sdcard: async MMC_WRITE_BLOCK_MULTIPLE finished\n"));
Expand Down Expand Up @@ -787,6 +796,9 @@ int sdcard_write(u32 blk_start, u32 blk_count, void *data)
goto retry_single;
}
return -1;
} else if(ISSET(cmd.c_flags, SCF_RSP_R1) && (MMC_R1(cmd.c_resp) & MMC_R1_ANY_ERROR)){
printf("sdcard: write reported error. status: %08lx\n", MMC_R1(cmd.c_resp));
return -2;
}
if(blk_count > 1)
DPRINTF(2, ("sdcard: MMC_WRITE_BLOCK_MULTIPLE done\n"));
Expand Down
5 changes: 0 additions & 5 deletions source/sdhc.c
Original file line number Diff line number Diff line change
Expand Up @@ -813,11 +813,6 @@ sdhc_transfer_data(struct sdhc_host *hp, struct sdmmc_command *cmd)
cmd->c_error = error;
SET(cmd->c_flags, SCF_ITSDONE);

if(!cmd->c_error && cmd->c_flags & SCF_RSP_R1 && MMC_R1(cmd->c_resp) & MMC_R1_ANY_ERROR){
printf("Card %lx reported error. status: %08lx\n", hp->ioh, MMC_R1(cmd->c_resp));
cmd->c_error = EREMOTEIO;
}

DPRINTF(1,("sdhc: data transfer done (error=%d)\n", cmd->c_error));
return;
}
Expand Down

0 comments on commit 21bee9a

Please sign in to comment.