Message ID | 20240625061015.24095-3-philmd@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | hw/sd/sd: Introduce sd_cmd_to_sendingdata() and sd_generic_read_byte() | expand |
On 25/6/24 08:10, Philippe Mathieu-Daudé wrote: > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > hw/sd/sd.c | 11 ++--------- > 1 file changed, 2 insertions(+), 9 deletions(-) > > diff --git a/hw/sd/sd.c b/hw/sd/sd.c > index 89006ba1b6..0011aa86da 100644 > --- a/hw/sd/sd.c > +++ b/hw/sd/sd.c > @@ -1220,10 +1220,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) > } > > sd_function_switch(sd, req.arg); > - sd->state = sd_sendingdata_state; > - sd->data_start = 0; > - sd->data_offset = 0; > - return sd_r1; > + return sd_cmd_to_sendingdata(sd, req, 0, NULL, 64); > > case 7: /* CMD7: SELECT/DESELECT_CARD */ > rca = sd_req_get_rca(sd, req); Oops, missing: -- >8 -- @@ -1068,3 +1068,2 @@ static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd, SDRequest req) -__attribute__((unused)) static sd_rsp_type_t sd_cmd_to_sendingdata(SDState *sd, SDRequest req, --- > @@ -1922,7 +1919,6 @@ send_response: > return rsplen; > } > > -__attribute__((unused)) > /* Return true when buffer consumed */ > static bool sd_generic_read_byte(SDState *sd, uint8_t *value) > { > @@ -2112,10 +2108,7 @@ uint8_t sd_read_byte(SDState *sd) > sd->current_cmd, sd->data_offset, io_len); > switch (sd->current_cmd) { > case 6: /* CMD6: SWITCH_FUNCTION */ > - ret = sd->data[sd->data_offset ++]; > - > - if (sd->data_offset >= 64) > - sd->state = sd_transfer_state; > + sd_generic_read_byte(sd, &ret); > break; > > case 9: /* CMD9: SEND_CSD */
diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 89006ba1b6..0011aa86da 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1220,10 +1220,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) } sd_function_switch(sd, req.arg); - sd->state = sd_sendingdata_state; - sd->data_start = 0; - sd->data_offset = 0; - return sd_r1; + return sd_cmd_to_sendingdata(sd, req, 0, NULL, 64); case 7: /* CMD7: SELECT/DESELECT_CARD */ rca = sd_req_get_rca(sd, req); @@ -1922,7 +1919,6 @@ send_response: return rsplen; } -__attribute__((unused)) /* Return true when buffer consumed */ static bool sd_generic_read_byte(SDState *sd, uint8_t *value) { @@ -2112,10 +2108,7 @@ uint8_t sd_read_byte(SDState *sd) sd->current_cmd, sd->data_offset, io_len); switch (sd->current_cmd) { case 6: /* CMD6: SWITCH_FUNCTION */ - ret = sd->data[sd->data_offset ++]; - - if (sd->data_offset >= 64) - sd->state = sd_transfer_state; + sd_generic_read_byte(sd, &ret); break; case 9: /* CMD9: SEND_CSD */
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- hw/sd/sd.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)