* [PATCH v2] mmc: tmio: enable odd number size access
@ 2014-09-10 1:29 Kuninori Morimoto
2014-09-10 7:11 ` Geert Uytterhoeven
0 siblings, 1 reply; 3+ messages in thread
From: Kuninori Morimoto @ 2014-09-10 1:29 UTC (permalink / raw)
To: Ulf Hansson, Chris Ball
Cc: Simon, Kuninori Morimoto, Linux-SH, linux-mmc, Shinobu Uehara
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Current tmio is using sd_ctrl_read16/write16_rep()
for data transfer.
It works if transfer size was even number,
but, last 1 byte will be ignored if
transfer size was odd number.
This patch adds new tmio_mmc_transfer_data()
and solve this issue.
Tested-by: Shinobu Uehara <shinobu.uehara.xc@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
v1 -> v2
- use u8 pointer only
- fix buf offset
- remove unneeded -1
drivers/mmc/host/tmio_mmc_pio.c | 46 +++++++++++++++++++++++++++++++++++----
1 file changed, 42 insertions(+), 4 deletions(-)
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index ff5ff0f..2ee0e21 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -376,6 +376,47 @@ static int tmio_mmc_start_command(struct tmio_mmc_host *host, struct mmc_command
return 0;
}
+static void tmio_mmc_transfer_data(struct tmio_mmc_host *host,
+ unsigned short *buf,
+ unsigned int count)
+{
+ int is_read = host->data->flags & MMC_DATA_READ;
+ u16 extra;
+ u8 *buf8;
+
+ /*
+ * Transfer the data
+ */
+ if (is_read)
+ sd_ctrl_read16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1);
+ else
+ sd_ctrl_write16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1);
+
+ /* count was even number */
+ if (!(count & 0x1))
+ return;
+
+ /* count was odd number */
+
+ buf8 = (u8 *)(buf + (count >> 1));
+
+ /*
+ * FIXME
+ *
+ * driver and this function are assuming that
+ * it is used as little endian
+ */
+ if (is_read) {
+ extra = sd_ctrl_read16(host, CTL_SD_DATA_PORT);
+
+ *buf8 = (u8)(extra & 0xff);
+ } else {
+ extra = (u16)(*buf8);
+
+ sd_ctrl_write16(host, CTL_SD_DATA_PORT, extra);
+ }
+}
+
/*
* This chip always returns (at least?) as much data as you ask for.
* I'm unsure what happens if you ask for less than a block. This should be
@@ -408,10 +449,7 @@ static void tmio_mmc_pio_irq(struct tmio_mmc_host *host)
count, host->sg_off, data->flags);
/* Transfer the data */
- if (data->flags & MMC_DATA_READ)
- sd_ctrl_read16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1);
- else
- sd_ctrl_write16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1);
+ tmio_mmc_transfer_data(host, buf, count);
host->sg_off += count;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] mmc: tmio: enable odd number size access
2014-09-10 1:29 [PATCH v2] mmc: tmio: enable odd number size access Kuninori Morimoto
@ 2014-09-10 7:11 ` Geert Uytterhoeven
2014-09-10 7:23 ` [PATCH v3] " Kuninori Morimoto
0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2014-09-10 7:11 UTC (permalink / raw)
To: Kuninori Morimoto
Cc: Ulf Hansson, Chris Ball, Simon, Kuninori Morimoto, Linux-SH,
linux-mmc, Shinobu Uehara
Hi Morimoto-san,
On Wed, Sep 10, 2014 at 3:29 AM, Kuninori Morimoto
<kuninori.morimoto.gx@gmail.com> wrote:
> + if (is_read) {
> + extra = sd_ctrl_read16(host, CTL_SD_DATA_PORT);
> +
> + *buf8 = (u8)(extra & 0xff);
> + } else {
> + extra = (u16)(*buf8);
> +
> + sd_ctrl_write16(host, CTL_SD_DATA_PORT, extra);
The casts to "u8" resp. "u16" are not needed.
You can even avoid introducing the "extra" variable:
if (is_read)
*buf8 = sd_ctrl_read16(host, CTL_SD_DATA_PORT) & 0xff;
else
sd_ctrl_write16(host, CTL_SD_DATA_PORT, *buf8);
Technically, the "& 0xff" is also not needed, but I'd keep it for clarity.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v3] mmc: tmio: enable odd number size access
2014-09-10 7:11 ` Geert Uytterhoeven
@ 2014-09-10 7:23 ` Kuninori Morimoto
0 siblings, 0 replies; 3+ messages in thread
From: Kuninori Morimoto @ 2014-09-10 7:23 UTC (permalink / raw)
To: Ulf Hansson
Cc: Geert Uytterhoeven, Chris Ball, Simon, Kuninori Morimoto,
Linux-SH, linux-mmc, Shinobu Uehara
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Current tmio is using sd_ctrl_read16/write16_rep()
for data transfer.
It works if transfer size was even number,
but, last 1 byte will be ignored if
transfer size was odd number.
This patch adds new tmio_mmc_transfer_data()
and solve this issue.
Tested-by: Shinobu Uehara <shinobu.uehara.xc@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
v2 -> v3
- remove cast
- remove extra variable
drivers/mmc/host/tmio_mmc_pio.c | 39 +++++++++++++++++++++++++++++++++++----
1 file changed, 35 insertions(+), 4 deletions(-)
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index ff5ff0f..692e578 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -376,6 +376,40 @@ static int tmio_mmc_start_command(struct tmio_mmc_host *host, struct mmc_command
return 0;
}
+static void tmio_mmc_transfer_data(struct tmio_mmc_host *host,
+ unsigned short *buf,
+ unsigned int count)
+{
+ int is_read = host->data->flags & MMC_DATA_READ;
+ u8 *buf8;
+
+ /*
+ * Transfer the data
+ */
+ if (is_read)
+ sd_ctrl_read16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1);
+ else
+ sd_ctrl_write16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1);
+
+ /* if count was even number */
+ if (!(count & 0x1))
+ return;
+
+ /* if count was odd number */
+ buf8 = (u8 *)(buf + (count >> 1));
+
+ /*
+ * FIXME
+ *
+ * driver and this function are assuming that
+ * it is used as little endian
+ */
+ if (is_read)
+ *buf8 = sd_ctrl_read16(host, CTL_SD_DATA_PORT) & 0xff;
+ else
+ sd_ctrl_write16(host, CTL_SD_DATA_PORT, *buf8);
+}
+
/*
* This chip always returns (at least?) as much data as you ask for.
* I'm unsure what happens if you ask for less than a block. This should be
@@ -408,10 +442,7 @@ static void tmio_mmc_pio_irq(struct tmio_mmc_host *host)
count, host->sg_off, data->flags);
/* Transfer the data */
- if (data->flags & MMC_DATA_READ)
- sd_ctrl_read16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1);
- else
- sd_ctrl_write16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1);
+ tmio_mmc_transfer_data(host, buf, count);
host->sg_off += count;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-09-10 7:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-10 1:29 [PATCH v2] mmc: tmio: enable odd number size access Kuninori Morimoto
2014-09-10 7:11 ` Geert Uytterhoeven
2014-09-10 7:23 ` [PATCH v3] " Kuninori Morimoto
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).