alloc_percpu: Use __get_cpu_ptr in drivers/dma

Impact: slight efficiency improvement on some archs.

Let's use __get_cpu_ptr and get_cpu_ptr now, rather than
per_cpu_ptr(..., smp_processor_id()).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: Maciej Sosnowski <maciej.sosnowski@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
---
 drivers/dma/dmaengine.c |   36 ++++++++++++++++--------------------
 1 file changed, 16 insertions(+), 20 deletions(-)

diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -326,17 +326,10 @@ arch_initcall(dma_channel_table_init);
  */
 struct dma_chan *dma_find_channel(enum dma_transaction_type tx_type)
 {
-	struct dma_chan *chan;
-	int cpu;
-
 	WARN_ONCE(dmaengine_ref_count == 0,
 		  "client called %s without a reference", __func__);
 
-	cpu = get_cpu();
-	chan = per_cpu_ptr(channel_table[tx_type], cpu)->chan;
-	put_cpu();
-
-	return chan;
+	return __raw_get_cpu_ptr(channel_table[tx_type])->chan;
 }
 EXPORT_SYMBOL(dma_find_channel);
 
@@ -772,6 +765,7 @@ dma_async_memcpy_buf_to_buf(struct dma_c
 	struct dma_async_tx_descriptor *tx;
 	dma_addr_t dma_dest, dma_src;
 	dma_cookie_t cookie;
+	struct dma_chan_percpu *local;
 	int cpu;
 
 	dma_src = dma_map_single(dev->dev, src, len, DMA_TO_DEVICE);
@@ -788,10 +782,10 @@ dma_async_memcpy_buf_to_buf(struct dma_c
 	tx->callback = NULL;
 	cookie = tx->tx_submit(tx);
 
-	cpu = get_cpu();
-	per_cpu_ptr(chan->local, cpu)->bytes_transferred += len;
-	per_cpu_ptr(chan->local, cpu)->memcpy_count++;
-	put_cpu();
+	local = get_cpu_ptr(chan->local);
+	local->bytes_transferred += len;
+	local->memcpy_count++;
+	put_cpu_ptr(chan->local);
 
 	return cookie;
 }
@@ -818,6 +812,7 @@ dma_async_memcpy_buf_to_pg(struct dma_ch
 	struct dma_async_tx_descriptor *tx;
 	dma_addr_t dma_dest, dma_src;
 	dma_cookie_t cookie;
+	struct dma_chan_percpu *local;
 	int cpu;
 
 	dma_src = dma_map_single(dev->dev, kdata, len, DMA_TO_DEVICE);
@@ -834,10 +829,10 @@ dma_async_memcpy_buf_to_pg(struct dma_ch
 	tx->callback = NULL;
 	cookie = tx->tx_submit(tx);
 
-	cpu = get_cpu();
-	per_cpu_ptr(chan->local, cpu)->bytes_transferred += len;
-	per_cpu_ptr(chan->local, cpu)->memcpy_count++;
-	put_cpu();
+	local = get_cpu_ptr(chan->local);
+	local->bytes_transferred += len;
+	local->memcpy_count++;
+	put_cpu_ptr(chan->local);
 
 	return cookie;
 }
@@ -866,6 +861,7 @@ dma_async_memcpy_pg_to_pg(struct dma_cha
 	struct dma_async_tx_descriptor *tx;
 	dma_addr_t dma_dest, dma_src;
 	dma_cookie_t cookie;
+	struct dma_chan_percpu *local;
 	int cpu;
 
 	dma_src = dma_map_page(dev->dev, src_pg, src_off, len, DMA_TO_DEVICE);
@@ -883,10 +879,10 @@ dma_async_memcpy_pg_to_pg(struct dma_cha
 	tx->callback = NULL;
 	cookie = tx->tx_submit(tx);
 
-	cpu = get_cpu();
-	per_cpu_ptr(chan->local, cpu)->bytes_transferred += len;
-	per_cpu_ptr(chan->local, cpu)->memcpy_count++;
-	put_cpu();
+	local = get_cpu_ptr(chan->local);
+	local->bytes_transferred += len;
+	local->memcpy_count++;
+	put_cpu_ptr(chan->local);
 
 	return cookie;
 }
