diff options
author | Mark Brown <broonie@kernel.org> | 2016-03-11 02:28:20 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-03-11 02:28:20 -0500 |
commit | a75481ab4a5276770e0fb7e137a4f170b90fc48b (patch) | |
tree | 9448ee69cceaa94c0dd0d8a538490b69153488c6 | |
parent | df9633a7805e6208fddd8248603a2543fe997b0a (diff) | |
parent | df88e91bbfd16662f3c8dcba27ad19e9eb4ebcef (diff) |
Merge remote-tracking branch 'spi/topic/dma' into spi-next
-rw-r--r-- | drivers/spi/spi.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 0b2bbf144460..89158c639e29 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
@@ -702,6 +702,7 @@ static int spi_map_buf(struct spi_master *master, struct device *dev, | |||
702 | enum dma_data_direction dir) | 702 | enum dma_data_direction dir) |
703 | { | 703 | { |
704 | const bool vmalloced_buf = is_vmalloc_addr(buf); | 704 | const bool vmalloced_buf = is_vmalloc_addr(buf); |
705 | unsigned int max_seg_size = dma_get_max_seg_size(dev); | ||
705 | int desc_len; | 706 | int desc_len; |
706 | int sgs; | 707 | int sgs; |
707 | struct page *vm_page; | 708 | struct page *vm_page; |
@@ -710,10 +711,10 @@ static int spi_map_buf(struct spi_master *master, struct device *dev, | |||
710 | int i, ret; | 711 | int i, ret; |
711 | 712 | ||
712 | if (vmalloced_buf) { | 713 | if (vmalloced_buf) { |
713 | desc_len = PAGE_SIZE; | 714 | desc_len = min_t(int, max_seg_size, PAGE_SIZE); |
714 | sgs = DIV_ROUND_UP(len + offset_in_page(buf), desc_len); | 715 | sgs = DIV_ROUND_UP(len + offset_in_page(buf), desc_len); |
715 | } else { | 716 | } else { |
716 | desc_len = master->max_dma_len; | 717 | desc_len = min_t(int, max_seg_size, master->max_dma_len); |
717 | sgs = DIV_ROUND_UP(len, desc_len); | 718 | sgs = DIV_ROUND_UP(len, desc_len); |
718 | } | 719 | } |
719 | 720 | ||
@@ -739,7 +740,6 @@ static int spi_map_buf(struct spi_master *master, struct device *dev, | |||
739 | sg_set_buf(&sgt->sgl[i], sg_buf, min); | 740 | sg_set_buf(&sgt->sgl[i], sg_buf, min); |
740 | } | 741 | } |
741 | 742 | ||
742 | |||
743 | buf += min; | 743 | buf += min; |
744 | len -= min; | 744 | len -= min; |
745 | } | 745 | } |