Skip to content

Commit 5b42778

Browse files
Christoph Hellwigstorulf
authored andcommitted
mmc: atmel-mci: use sg_copy_{from,to}_buffer
This handles highmem pages, and also cleans up the code. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 53d7e09 commit 5b42778

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

drivers/mmc/host/atmel-mci.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,7 +1967,6 @@ static void atmci_tasklet_func(unsigned long priv)
19671967
static void atmci_read_data_pio(struct atmel_mci *host)
19681968
{
19691969
struct scatterlist *sg = host->sg;
1970-
void *buf = sg_virt(sg);
19711970
unsigned int offset = host->pio_offset;
19721971
struct mmc_data *data = host->data;
19731972
u32 value;
@@ -1977,7 +1976,7 @@ static void atmci_read_data_pio(struct atmel_mci *host)
19771976
do {
19781977
value = atmci_readl(host, ATMCI_RDR);
19791978
if (likely(offset + 4 <= sg->length)) {
1980-
put_unaligned(value, (u32 *)(buf + offset));
1979+
sg_pcopy_to_buffer(sg, 1, &value, sizeof(u32), offset);
19811980

19821981
offset += 4;
19831982
nbytes += 4;
@@ -1990,11 +1989,11 @@ static void atmci_read_data_pio(struct atmel_mci *host)
19901989
goto done;
19911990

19921991
offset = 0;
1993-
buf = sg_virt(sg);
19941992
}
19951993
} else {
19961994
unsigned int remaining = sg->length - offset;
1997-
memcpy(buf + offset, &value, remaining);
1995+
1996+
sg_pcopy_to_buffer(sg, 1, &value, remaining, offset);
19981997
nbytes += remaining;
19991998

20001999
flush_dcache_page(sg_page(sg));
@@ -2004,8 +2003,8 @@ static void atmci_read_data_pio(struct atmel_mci *host)
20042003
goto done;
20052004

20062005
offset = 4 - remaining;
2007-
buf = sg_virt(sg);
2008-
memcpy(buf, (u8 *)&value + remaining, offset);
2006+
sg_pcopy_to_buffer(sg, 1, (u8 *)&value + remaining,
2007+
offset, 0);
20092008
nbytes += offset;
20102009
}
20112010

@@ -2035,7 +2034,6 @@ static void atmci_read_data_pio(struct atmel_mci *host)
20352034
static void atmci_write_data_pio(struct atmel_mci *host)
20362035
{
20372036
struct scatterlist *sg = host->sg;
2038-
void *buf = sg_virt(sg);
20392037
unsigned int offset = host->pio_offset;
20402038
struct mmc_data *data = host->data;
20412039
u32 value;
@@ -2044,7 +2042,7 @@ static void atmci_write_data_pio(struct atmel_mci *host)
20442042

20452043
do {
20462044
if (likely(offset + 4 <= sg->length)) {
2047-
value = get_unaligned((u32 *)(buf + offset));
2045+
sg_pcopy_from_buffer(sg, 1, &value, sizeof(u32), offset);
20482046
atmci_writel(host, ATMCI_TDR, value);
20492047

20502048
offset += 4;
@@ -2056,13 +2054,12 @@ static void atmci_write_data_pio(struct atmel_mci *host)
20562054
goto done;
20572055

20582056
offset = 0;
2059-
buf = sg_virt(sg);
20602057
}
20612058
} else {
20622059
unsigned int remaining = sg->length - offset;
20632060

20642061
value = 0;
2065-
memcpy(&value, buf + offset, remaining);
2062+
sg_pcopy_from_buffer(sg, 1, &value, remaining, offset);
20662063
nbytes += remaining;
20672064

20682065
host->sg = sg = sg_next(sg);
@@ -2073,8 +2070,8 @@ static void atmci_write_data_pio(struct atmel_mci *host)
20732070
}
20742071

20752072
offset = 4 - remaining;
2076-
buf = sg_virt(sg);
2077-
memcpy((u8 *)&value + remaining, buf, offset);
2073+
sg_pcopy_from_buffer(sg, 1, (u8 *)&value + remaining,
2074+
offset, 0);
20782075
atmci_writel(host, ATMCI_TDR, value);
20792076
nbytes += offset;
20802077
}

0 commit comments

Comments
 (0)