Straightforward conversion, except due to the lack of error path we have to WARN if the memory in the SGL is not mappable. Signed-off-by: Logan Gunthorpe <logang@xxxxxxxxxxxx> --- drivers/mmc/host/sdhci.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 63bc33a..af0c107 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -497,15 +497,34 @@ static int sdhci_pre_dma_transfer(struct sdhci_host *host, return sg_count; } +/* + * Note this function may return PTR_ERR and must be checked. + */ static char *sdhci_kmap_atomic(struct scatterlist *sg, unsigned long *flags) { + void *ret; + local_irq_save(*flags); - return kmap_atomic(sg_page(sg)) + sg->offset; + + ret = sg_map(sg, SG_KMAP_ATOMIC); + if (IS_ERR(ret)) { + /* + * This should really never happen unless the code is changed + * to use memory that is not mappable in the sg. Seeing there + * doesn't seem to be any error path out of here, we can only + * WARN. + */ + WARN(1, "Non-mappable memory used in sg!"); + local_irq_restore(*flags); + } + + return ret; } -static void sdhci_kunmap_atomic(void *buffer, unsigned long *flags) +static void sdhci_kunmap_atomic(struct scatterlist *sg, void *buffer, + unsigned long *flags) { - kunmap_atomic(buffer); + sg_unmap(sg, buffer, SG_KMAP_ATOMIC); local_irq_restore(*flags); } @@ -568,8 +587,11 @@ static void sdhci_adma_table_pre(struct sdhci_host *host, if (offset) { if (data->flags & MMC_DATA_WRITE) { buffer = sdhci_kmap_atomic(sg, &flags); + if (IS_ERR(buffer)) + return; + memcpy(align, buffer, offset); - sdhci_kunmap_atomic(buffer, &flags); + sdhci_kunmap_atomic(sg, buffer, &flags); } /* tran, valid */ @@ -646,8 +668,11 @@ static void sdhci_adma_table_post(struct sdhci_host *host, (sg_dma_address(sg) & SDHCI_ADMA2_MASK); buffer = sdhci_kmap_atomic(sg, &flags); + if (IS_ERR(buffer)) + return; + memcpy(buffer, align, size); - sdhci_kunmap_atomic(buffer, &flags); + sdhci_kunmap_atomic(sg, buffer, &flags); align += SDHCI_ADMA2_ALIGN; } -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html