Skip to content

Commit 19f5e9e

Browse files
ldesrochesUlf Hansson
authored andcommitted
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: Ludovic Desroches <ludovic.desroches@microchip.com> Suggested-by: Douglas Gilbert <dgilbert@interlog.com> Fixes: 5b42778 ("mmc: atmel-mci: use sg_copy_{from,to}_buffer") Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 778a339 commit 19f5e9e

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎drivers/mmc/host/atmel-mci.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,7 +1976,7 @@ static void atmci_read_data_pio(struct atmel_mci *host)
19761976
do {
19771977
value = atmci_readl(host, ATMCI_RDR);
19781978
if (likely(offset + 4 <= sg->length)) {
1979-
sg_pcopy_to_buffer(sg, 1, &value, sizeof(u32), offset);
1979+
sg_pcopy_from_buffer(sg, 1, &value, sizeof(u32), offset);
19801980

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

1996-
sg_pcopy_to_buffer(sg, 1, &value, remaining, offset);
1996+
sg_pcopy_from_buffer(sg, 1, &value, remaining, offset);
19971997
nbytes += remaining;
19981998

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

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

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

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

20612061
value = 0;
2062-
sg_pcopy_from_buffer(sg, 1, &value, remaining, offset);
2062+
sg_pcopy_to_buffer(sg, 1, &value, remaining, offset);
20632063
nbytes += remaining;
20642064

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

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

0 commit comments

Comments
 (0)