Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 19f5e9e0 authored by Ludovic Desroches's avatar Ludovic Desroches Committed by Ulf Hansson
Browse files

mmc: atmel-mci: fix bad logic of sg_copy_{from,to}_buffer conversion



The conversion to sg_copy_{from,to}_buffer has been done in the wrong
way. sg_copy_to_buffer is a copy from an SG list to a linear buffer so
it can't replace memcpy(buf + offset, &value, remaining) where buf is
the virtual address of the SG. Same for sg_copy_to_buffer but in the
opposite way.

Signed-off-by: default avatarLudovic Desroches <ludovic.desroches@microchip.com>
Suggested-by: default avatarDouglas Gilbert <dgilbert@interlog.com>
Fixes: 5b427781 ("mmc: atmel-mci: use sg_copy_{from,to}_buffer")
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 778a3395
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -1976,7 +1976,7 @@ static void atmci_read_data_pio(struct atmel_mci *host)
	do {
		value = atmci_readl(host, ATMCI_RDR);
		if (likely(offset + 4 <= sg->length)) {
			sg_pcopy_to_buffer(sg, 1, &value, sizeof(u32), offset);
			sg_pcopy_from_buffer(sg, 1, &value, sizeof(u32), offset);

			offset += 4;
			nbytes += 4;
@@ -1993,7 +1993,7 @@ static void atmci_read_data_pio(struct atmel_mci *host)
		} else {
			unsigned int remaining = sg->length - offset;

			sg_pcopy_to_buffer(sg, 1, &value, remaining, offset);
			sg_pcopy_from_buffer(sg, 1, &value, remaining, offset);
			nbytes += remaining;

			flush_dcache_page(sg_page(sg));
@@ -2003,7 +2003,7 @@ static void atmci_read_data_pio(struct atmel_mci *host)
				goto done;

			offset = 4 - remaining;
			sg_pcopy_to_buffer(sg, 1, (u8 *)&value + remaining,
			sg_pcopy_from_buffer(sg, 1, (u8 *)&value + remaining,
					offset, 0);
			nbytes += offset;
		}
@@ -2042,7 +2042,7 @@ static void atmci_write_data_pio(struct atmel_mci *host)

	do {
		if (likely(offset + 4 <= sg->length)) {
			sg_pcopy_from_buffer(sg, 1, &value, sizeof(u32), offset);
			sg_pcopy_to_buffer(sg, 1, &value, sizeof(u32), offset);
			atmci_writel(host, ATMCI_TDR, value);

			offset += 4;
@@ -2059,7 +2059,7 @@ static void atmci_write_data_pio(struct atmel_mci *host)
			unsigned int remaining = sg->length - offset;

			value = 0;
			sg_pcopy_from_buffer(sg, 1, &value, remaining, offset);
			sg_pcopy_to_buffer(sg, 1, &value, remaining, offset);
			nbytes += remaining;

			host->sg = sg = sg_next(sg);
@@ -2070,7 +2070,7 @@ static void atmci_write_data_pio(struct atmel_mci *host)
			}

			offset = 4 - remaining;
			sg_pcopy_from_buffer(sg, 1, (u8 *)&value + remaining,
			sg_pcopy_to_buffer(sg, 1, (u8 *)&value + remaining,
					offset, 0);
			atmci_writel(host, ATMCI_TDR, value);
			nbytes += offset;