[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 17/23] hw/sd: Rename sdbus_read_data() as sdbus_read_byte()
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 17/23] hw/sd: Rename sdbus_read_data() as sdbus_read_byte() |
Date: |
Fri, 21 Aug 2020 19:29:10 +0200 |
The sdbus_read_data() method do a single byte access on the data
line of a SD bus. Rename it as sdbus_read_byte() and document it.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20200814092346.21825-4-f4bug@amsat.org>
---
include/hw/sd/sd.h | 10 +++++++++-
hw/sd/allwinner-sdhost.c | 10 +++++-----
hw/sd/bcm2835_sdhost.c | 2 +-
hw/sd/core.c | 2 +-
hw/sd/milkymist-memcard.c | 8 ++++----
hw/sd/pl181.c | 2 +-
hw/sd/pxa2xx_mmci.c | 2 +-
hw/sd/sdhci.c | 8 ++++----
hw/sd/ssi-sd.c | 2 +-
9 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/include/hw/sd/sd.h b/include/hw/sd/sd.h
index 1e5ac955d05..14ffc7f4758 100644
--- a/include/hw/sd/sd.h
+++ b/include/hw/sd/sd.h
@@ -166,7 +166,15 @@ int sdbus_do_command(SDBus *sd, SDRequest *req, uint8_t
*response);
* Write a byte on the data lines of a SD bus.
*/
void sdbus_write_byte(SDBus *sd, uint8_t value);
-uint8_t sdbus_read_data(SDBus *sd);
+/**
+ * Read a byte from a SD bus.
+ * @sd: bus
+ *
+ * Read a byte from the data lines of a SD bus.
+ *
+ * Return: byte value read
+ */
+uint8_t sdbus_read_byte(SDBus *sd);
bool sdbus_data_ready(SDBus *sd);
bool sdbus_get_inserted(SDBus *sd);
bool sdbus_get_readonly(SDBus *sd);
diff --git a/hw/sd/allwinner-sdhost.c b/hw/sd/allwinner-sdhost.c
index e05e8a3864c..c004aa39da6 100644
--- a/hw/sd/allwinner-sdhost.c
+++ b/hw/sd/allwinner-sdhost.c
@@ -341,7 +341,7 @@ static uint32_t allwinner_sdhost_process_desc(AwSdHostState
*s,
/* Read from SD bus */
} else {
for (uint32_t i = 0; i < buf_bytes; i++) {
- buf[i] = sdbus_read_data(&s->sdbus);
+ buf[i] = sdbus_read_byte(&s->sdbus);
}
cpu_physical_memory_write((desc->addr & DESC_SIZE_MASK) + num_done,
buf, buf_bytes);
@@ -521,10 +521,10 @@ static uint64_t allwinner_sdhost_read(void *opaque,
hwaddr offset,
break;
case REG_SD_FIFO: /* Read/Write FIFO */
if (sdbus_data_ready(&s->sdbus)) {
- res = sdbus_read_data(&s->sdbus);
- res |= sdbus_read_data(&s->sdbus) << 8;
- res |= sdbus_read_data(&s->sdbus) << 16;
- res |= sdbus_read_data(&s->sdbus) << 24;
+ res = sdbus_read_byte(&s->sdbus);
+ res |= sdbus_read_byte(&s->sdbus) << 8;
+ res |= sdbus_read_byte(&s->sdbus) << 16;
+ res |= sdbus_read_byte(&s->sdbus) << 24;
allwinner_sdhost_update_transfer_cnt(s, sizeof(uint32_t));
allwinner_sdhost_auto_stop(s);
allwinner_sdhost_update_irq(s);
diff --git a/hw/sd/bcm2835_sdhost.c b/hw/sd/bcm2835_sdhost.c
index 16aba7cc92b..2c7a675a2d8 100644
--- a/hw/sd/bcm2835_sdhost.c
+++ b/hw/sd/bcm2835_sdhost.c
@@ -190,7 +190,7 @@ static void bcm2835_sdhost_fifo_run(BCM2835SDHostState *s)
if (is_read) {
n = 0;
while (s->datacnt && s->fifo_len < BCM2835_SDHOST_FIFO_LEN) {
- value |= (uint32_t)sdbus_read_data(&s->sdbus) << (n * 8);
+ value |= (uint32_t)sdbus_read_byte(&s->sdbus) << (n * 8);
s->datacnt--;
n++;
if (n == 4) {
diff --git a/hw/sd/core.c b/hw/sd/core.c
index 13b5ca03169..a3b620b802b 100644
--- a/hw/sd/core.c
+++ b/hw/sd/core.c
@@ -114,7 +114,7 @@ void sdbus_write_byte(SDBus *sdbus, uint8_t value)
}
}
-uint8_t sdbus_read_data(SDBus *sdbus)
+uint8_t sdbus_read_byte(SDBus *sdbus)
{
SDState *card = get_card(sdbus);
uint8_t value = 0;
diff --git a/hw/sd/milkymist-memcard.c b/hw/sd/milkymist-memcard.c
index 4128109c047..e8d055bb895 100644
--- a/hw/sd/milkymist-memcard.c
+++ b/hw/sd/milkymist-memcard.c
@@ -152,10 +152,10 @@ static uint64_t memcard_read(void *opaque, hwaddr addr,
r = 0xffffffff;
} else {
r = 0;
- r |= sdbus_read_data(&s->sdbus) << 24;
- r |= sdbus_read_data(&s->sdbus) << 16;
- r |= sdbus_read_data(&s->sdbus) << 8;
- r |= sdbus_read_data(&s->sdbus);
+ r |= sdbus_read_byte(&s->sdbus) << 24;
+ r |= sdbus_read_byte(&s->sdbus) << 16;
+ r |= sdbus_read_byte(&s->sdbus) << 8;
+ r |= sdbus_read_byte(&s->sdbus);
}
break;
case R_CLK2XDIV:
diff --git a/hw/sd/pl181.c b/hw/sd/pl181.c
index 771bae193f5..579d68ad83e 100644
--- a/hw/sd/pl181.c
+++ b/hw/sd/pl181.c
@@ -223,7 +223,7 @@ static void pl181_fifo_run(PL181State *s)
if (is_read) {
n = 0;
while (s->datacnt && s->fifo_len < PL181_FIFO_LEN) {
- value |= (uint32_t)sdbus_read_data(&s->sdbus) << (n * 8);
+ value |= (uint32_t)sdbus_read_byte(&s->sdbus) << (n * 8);
s->datacnt--;
n++;
if (n == 4) {
diff --git a/hw/sd/pxa2xx_mmci.c b/hw/sd/pxa2xx_mmci.c
index 07ddc2eba3e..04f0a98f813 100644
--- a/hw/sd/pxa2xx_mmci.c
+++ b/hw/sd/pxa2xx_mmci.c
@@ -194,7 +194,7 @@ static void pxa2xx_mmci_fifo_update(PXA2xxMMCIState *s)
} else
while (s->bytesleft && s->rx_len < 32) {
s->rx_fifo[(s->rx_start + (s->rx_len ++)) & 0x1f] =
- sdbus_read_data(&s->sdbus);
+ sdbus_read_byte(&s->sdbus);
s->bytesleft --;
s->intreq |= INT_RXFIFO_REQ;
}
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
index 4bf1ee88b2a..b897b1121b8 100644
--- a/hw/sd/sdhci.c
+++ b/hw/sd/sdhci.c
@@ -409,7 +409,7 @@ static void sdhci_read_block_from_card(SDHCIState *s)
}
for (index = 0; index < blk_size; index++) {
- data = sdbus_read_data(&s->sdbus);
+ data = sdbus_read_byte(&s->sdbus);
if (!FIELD_EX32(s->hostctl2, SDHC_HOSTCTL2, EXECUTE_TUNING)) {
/* Device is not in tuning */
s->fifo_buffer[index] = data;
@@ -601,7 +601,7 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
while (s->blkcnt) {
if (s->data_count == 0) {
for (n = 0; n < block_size; n++) {
- s->fifo_buffer[n] = sdbus_read_data(&s->sdbus);
+ s->fifo_buffer[n] = sdbus_read_byte(&s->sdbus);
}
}
begin = s->data_count;
@@ -673,7 +673,7 @@ static void sdhci_sdma_transfer_single_block(SDHCIState *s)
if (s->trnmod & SDHC_TRNS_READ) {
for (n = 0; n < datacnt; n++) {
- s->fifo_buffer[n] = sdbus_read_data(&s->sdbus);
+ s->fifo_buffer[n] = sdbus_read_byte(&s->sdbus);
}
dma_memory_write(s->dma_as, s->sdmasysad, s->fifo_buffer, datacnt);
} else {
@@ -774,7 +774,7 @@ static void sdhci_do_adma(SDHCIState *s)
while (length) {
if (s->data_count == 0) {
for (n = 0; n < block_size; n++) {
- s->fifo_buffer[n] = sdbus_read_data(&s->sdbus);
+ s->fifo_buffer[n] = sdbus_read_byte(&s->sdbus);
}
}
begin = s->data_count;
diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c
index 9210ef567f1..a7ef9cb9225 100644
--- a/hw/sd/ssi-sd.c
+++ b/hw/sd/ssi-sd.c
@@ -190,7 +190,7 @@ static uint32_t ssi_sd_transfer(SSISlave *dev, uint32_t val)
s->mode = SSI_SD_DATA_READ;
return 0xfe;
case SSI_SD_DATA_READ:
- val = sdbus_read_data(&s->sdbus);
+ val = sdbus_read_byte(&s->sdbus);
if (!sdbus_data_ready(&s->sdbus)) {
DPRINTF("Data read end\n");
s->mode = SSI_SD_CMD;
--
2.26.2
- [PULL 09/23] hw/sd/pl181: Use named GPIOs, (continued)
- [PULL 09/23] hw/sd/pl181: Use named GPIOs, Philippe Mathieu-Daudé, 2020/08/21
- [PULL 10/23] hw/sd/pl181: Expose a SDBus and connect the SDCard to it, Philippe Mathieu-Daudé, 2020/08/21
- [PULL 11/23] hw/sd/pl181: Do not create SD card within the SD host controller, Philippe Mathieu-Daudé, 2020/08/21
- [PULL 12/23] hw/sd/pl181: Replace disabled fprintf()s by trace events, Philippe Mathieu-Daudé, 2020/08/21
- [PULL 14/23] hw/sd: Move sdcard legacy API to 'hw/sd/sdcard_legacy.h', Philippe Mathieu-Daudé, 2020/08/21
- [PULL 13/23] hw/sd/sdcard: Make sd_data_ready() static, Philippe Mathieu-Daudé, 2020/08/21
- [PULL 15/23] hw/sd: Rename read/write_data() as read/write_byte(), Philippe Mathieu-Daudé, 2020/08/21
- [PULL 16/23] hw/sd: Rename sdbus_write_data() as sdbus_write_byte(), Philippe Mathieu-Daudé, 2020/08/21
- [PULL 18/23] hw/sd: Add sdbus_write_data() to write multiples bytes on the data line, Philippe Mathieu-Daudé, 2020/08/21
- [PULL 20/23] hw/sd: Add sdbus_read_data() to read multiples bytes on the data line, Philippe Mathieu-Daudé, 2020/08/21
- [PULL 17/23] hw/sd: Rename sdbus_read_data() as sdbus_read_byte(),
Philippe Mathieu-Daudé <=
- [PULL 21/23] hw/sd: Use sdbus_read_data() instead of sdbus_read_byte() when possible, Philippe Mathieu-Daudé, 2020/08/21
- [PULL 19/23] hw/sd: Use sdbus_write_data() instead of sdbus_write_byte when possible, Philippe Mathieu-Daudé, 2020/08/21
- [PULL 23/23] hw/sd: Correct the maximum size of a Standard Capacity SD Memory Card, Philippe Mathieu-Daudé, 2020/08/21
- [PULL 22/23] hw/sd: Fix incorrect populated function switch status data structure, Philippe Mathieu-Daudé, 2020/08/21
- Re: [PULL 00/23] SD/MMC patches for 2020-08-21, Peter Maydell, 2020/08/23