[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH V3 10/13] SD card users: optimize access to SDClass
From: |
Igor Mitsyanko |
Subject: |
[Qemu-devel] [PATCH V3 10/13] SD card users: optimize access to SDClass methods |
Date: |
Fri, 27 Apr 2012 19:50:56 +0400 |
Rather that repeatedly call SD_GET_CLASS() in a loop, call it once before
a loop starts.
Signed-off-by: Igor Mitsyanko <address@hidden>
---
hw/omap_mmc.c | 9 +++++----
hw/pl181.c | 7 ++++---
hw/pxa2xx_mmci.c | 6 ++++--
3 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/hw/omap_mmc.c b/hw/omap_mmc.c
index aec0285..8ceb25b 100644
--- a/hw/omap_mmc.c
+++ b/hw/omap_mmc.c
@@ -219,6 +219,7 @@ static void omap_mmc_command(struct omap_mmc_s *host, int
cmd, int dir,
static void omap_mmc_transfer(struct omap_mmc_s *host)
{
+ SDClass *sd_class = SD_GET_CLASS(host->card);
uint8_t value;
if (!host->transfer)
@@ -229,10 +230,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_class->read_data(host->card);
host->fifo[(host->fifo_start + host->fifo_len) & 31] = value;
if (-- host->blen_counter) {
- value = sd_read_data(host->card);
+ value = sd_class->read_data(host->card);
host->fifo[(host->fifo_start + host->fifo_len) & 31] |=
value << 8;
host->blen_counter --;
@@ -244,10 +245,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_class->write_data(host->card, value);
if (-- host->blen_counter) {
value = host->fifo[host->fifo_start] >> 8;
- sd_write_data(host->card, value);
+ sd_class->write_data(host->card, value);
host->blen_counter --;
}
diff --git a/hw/pl181.c b/hw/pl181.c
index 7d91fbb..8cd898c 100644
--- a/hw/pl181.c
+++ b/hw/pl181.c
@@ -209,18 +209,19 @@ error:
static void pl181_fifo_run(pl181_state *s)
{
+ SDClass *sd_class = SD_GET_CLASS(s->card);
uint32_t bits;
uint32_t value = 0;
int n;
int is_read;
is_read = (s->datactrl & PL181_DATA_DIRECTION) != 0;
- if (s->datacnt != 0 && (!is_read || sd_data_ready(s->card))
+ if (s->datacnt != 0 && (!is_read || sd_class->data_ready(s->card))
&& !s->linux_hack) {
if (is_read) {
n = 0;
while (s->datacnt && s->fifo_len < PL181_FIFO_LEN) {
- value |= (uint32_t)sd_read_data(s->card) << (n * 8);
+ value |= (uint32_t)sd_class->read_data(s->card) << (n * 8);
s->datacnt--;
n++;
if (n == 4) {
@@ -241,7 +242,7 @@ static void pl181_fifo_run(pl181_state *s)
}
n--;
s->datacnt--;
- sd_write_data(s->card, value & 0xff);
+ sd_class->write_data(s->card, value & 0xff);
value >>= 8;
}
}
diff --git a/hw/pxa2xx_mmci.c b/hw/pxa2xx_mmci.c
index b505a4c..af19c36 100644
--- a/hw/pxa2xx_mmci.c
+++ b/hw/pxa2xx_mmci.c
@@ -117,12 +117,14 @@ static void pxa2xx_mmci_int_update(PXA2xxMMCIState *s)
static void pxa2xx_mmci_fifo_update(PXA2xxMMCIState *s)
{
+ SDClass *sd_class = SD_GET_CLASS(s->card);
+
if (!s->active)
return;
if (s->cmdat & CMDAT_WR_RD) {
while (s->bytesleft && s->tx_len) {
- sd_write_data(s->card, s->tx_fifo[s->tx_start ++]);
+ sd_class->write_data(s->card, s->tx_fifo[s->tx_start ++]);
s->tx_start &= 0x1f;
s->tx_len --;
s->bytesleft --;
@@ -132,7 +134,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] =
- sd_read_data(s->card);
+ sd_class->read_data(s->card);
s->bytesleft --;
s->intreq |= INT_RXFIFO_REQ;
}
--
1.7.4.1
- [Qemu-devel] [PATCH V3 01/13] hw/sd.c: convert wp_groups in SDState to bitfield, (continued)
[Qemu-devel] [PATCH V3 11/13] SD card: introduce "spi" property for SD card objects, Igor Mitsyanko, 2012/04/27
[Qemu-devel] [PATCH V3 10/13] SD card users: optimize access to SDClass methods,
Igor Mitsyanko <=
[Qemu-devel] [PATCH V3 13/13] hw/sd.c: introduce "eject" property for SD card objects, Igor Mitsyanko, 2012/04/27