hw/sd: Rename read/write_data() as read/write_byte()

The read/write_data() methods write do a single byte access
on the data line of a SD card. Rename them as read/write_byte().
Add some documentation (not in "hw/sd/sdcard_legacy.h" which we
are going to remove soon).

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20200814092346.21825-2-f4bug@amsat.org>
This commit is contained in:
Philippe Mathieu-Daudé 2020-08-14 11:23:40 +02:00
parent 9006f1e706
commit c769a88d44
5 changed files with 33 additions and 18 deletions

View file

@ -110,7 +110,7 @@ void sdbus_write_data(SDBus *sdbus, uint8_t value)
if (card) {
SDCardClass *sc = SD_CARD_GET_CLASS(card);
sc->write_data(card, value);
sc->write_byte(card, value);
}
}
@ -122,7 +122,7 @@ uint8_t sdbus_read_data(SDBus *sdbus)
if (card) {
SDCardClass *sc = SD_CARD_GET_CLASS(card);
value = sc->read_data(card);
value = sc->read_byte(card);
}
trace_sdbus_read(sdbus_name(sdbus), value);

View file

@ -232,10 +232,10 @@ static void omap_mmc_transfer(struct omap_mmc_s *host)
if (host->fifo_len > host->af_level)
break;
value = sd_read_data(host->card);
value = sd_read_byte(host->card);
host->fifo[(host->fifo_start + host->fifo_len) & 31] = value;
if (-- host->blen_counter) {
value = sd_read_data(host->card);
value = sd_read_byte(host->card);
host->fifo[(host->fifo_start + host->fifo_len) & 31] |=
value << 8;
host->blen_counter --;
@ -247,10 +247,10 @@ static void omap_mmc_transfer(struct omap_mmc_s *host)
break;
value = host->fifo[host->fifo_start] & 0xff;
sd_write_data(host->card, value);
sd_write_byte(host->card, value);
if (-- host->blen_counter) {
value = host->fifo[host->fifo_start] >> 8;
sd_write_data(host->card, value);
sd_write_byte(host->card, value);
host->blen_counter --;
}

View file

@ -1809,7 +1809,7 @@ static void sd_blk_write(SDState *sd, uint64_t addr, uint32_t len)
#define APP_READ_BLOCK(a, len) memset(sd->data, 0xec, len)
#define APP_WRITE_BLOCK(a, len)
void sd_write_data(SDState *sd, uint8_t value)
void sd_write_byte(SDState *sd, uint8_t value)
{
int i;
@ -1818,7 +1818,7 @@ void sd_write_data(SDState *sd, uint8_t value)
if (sd->state != sd_receivingdata_state) {
qemu_log_mask(LOG_GUEST_ERROR,
"sd_write_data: not in Receiving-Data state\n");
"%s: not in Receiving-Data state\n", __func__);
return;
}
@ -1940,7 +1940,7 @@ void sd_write_data(SDState *sd, uint8_t value)
break;
default:
qemu_log_mask(LOG_GUEST_ERROR, "sd_write_data: unknown command\n");
qemu_log_mask(LOG_GUEST_ERROR, "%s: unknown command\n", __func__);
break;
}
}
@ -1959,7 +1959,7 @@ static const uint8_t sd_tuning_block_pattern[SD_TUNING_BLOCK_SIZE] = {
0xbb, 0xff, 0xf7, 0xff, 0xf7, 0x7f, 0x7b, 0xde,
};
uint8_t sd_read_data(SDState *sd)
uint8_t sd_read_byte(SDState *sd)
{
/* TODO: Append CRCs */
uint8_t ret;
@ -1970,7 +1970,7 @@ uint8_t sd_read_data(SDState *sd)
if (sd->state != sd_sendingdata_state) {
qemu_log_mask(LOG_GUEST_ERROR,
"sd_read_data: not in Sending-Data state\n");
"%s: not in Sending-Data state\n", __func__);
return 0x00;
}
@ -2076,7 +2076,7 @@ uint8_t sd_read_data(SDState *sd)
break;
default:
qemu_log_mask(LOG_GUEST_ERROR, "sd_read_data: unknown command\n");
qemu_log_mask(LOG_GUEST_ERROR, "%s: unknown command\n", __func__);
return 0x00;
}
@ -2192,8 +2192,8 @@ static void sd_class_init(ObjectClass *klass, void *data)
sc->get_dat_lines = sd_get_dat_lines;
sc->get_cmd_line = sd_get_cmd_line;
sc->do_command = sd_do_command;
sc->write_data = sd_write_data;
sc->read_data = sd_read_data;
sc->write_byte = sd_write_byte;
sc->read_byte = sd_read_byte;
sc->data_ready = sd_data_ready;
sc->enable = sd_enable;
sc->get_inserted = sd_get_inserted;

View file

@ -104,8 +104,23 @@ typedef struct {
/*< public >*/
int (*do_command)(SDState *sd, SDRequest *req, uint8_t *response);
void (*write_data)(SDState *sd, uint8_t value);
uint8_t (*read_data)(SDState *sd);
/**
* Write a byte to a SD card.
* @sd: card
* @value: byte to write
*
* Write a byte on the data lines of a SD card.
*/
void (*write_byte)(SDState *sd, uint8_t value);
/**
* Read a byte from a SD card.
* @sd: card
*
* Read a byte from the data lines of a SD card.
*
* Return: byte value read
*/
uint8_t (*read_byte)(SDState *sd);
bool (*data_ready)(SDState *sd);
void (*set_voltage)(SDState *sd, uint16_t millivolts);
uint8_t (*get_dat_lines)(SDState *sd);

View file

@ -34,8 +34,8 @@
/* Legacy functions to be used only by non-qdevified callers */
SDState *sd_init(BlockBackend *blk, bool is_spi);
int sd_do_command(SDState *card, SDRequest *request, uint8_t *response);
void sd_write_data(SDState *card, uint8_t value);
uint8_t sd_read_data(SDState *card);
void sd_write_byte(SDState *card, uint8_t value);
uint8_t sd_read_byte(SDState *card);
void sd_set_cb(SDState *card, qemu_irq readonly, qemu_irq insert);
/* sd_enable should not be used -- it is only used on the nseries boards,