mmc: queue: Factor out mmc_queue_alloc_sgs()
authorAdrian Hunter <adrian.hunter@intel.com>
Tue, 29 Nov 2016 10:09:13 +0000 (12:09 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 5 Dec 2016 09:31:05 +0000 (10:31 +0100)
In preparation for supporting a queue of requests, factor out
mmc_queue_alloc_sgs().

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Harjani Ritesh <riteshh@codeaurora.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/card/queue.c

index 46b7b1f0cade256b43b693a76463e8880bc8caac..280708d804b9abc4cfecad58c82ece40173dd13a 100644 (file)
@@ -237,6 +237,21 @@ static int mmc_queue_alloc_bounce_sgs(struct mmc_queue *mq,
 }
 #endif
 
+static int mmc_queue_alloc_sgs(struct mmc_queue *mq, int max_segs)
+{
+       struct mmc_queue_req *mqrq_cur = mq->mqrq_cur;
+       struct mmc_queue_req *mqrq_prev = mq->mqrq_prev;
+       int ret;
+
+       mqrq_cur->sg = mmc_alloc_sg(max_segs, &ret);
+       if (ret)
+               return ret;
+
+       mqrq_prev->sg = mmc_alloc_sg(max_segs, &ret);
+
+       return ret;
+}
+
 /**
  * mmc_init_queue - initialise a queue structure.
  * @mq: mmc queue
@@ -309,12 +324,7 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card,
                blk_queue_max_segments(mq->queue, host->max_segs);
                blk_queue_max_segment_size(mq->queue, host->max_seg_size);
 
-               mqrq_cur->sg = mmc_alloc_sg(host->max_segs, &ret);
-               if (ret)
-                       goto cleanup_queue;
-
-
-               mqrq_prev->sg = mmc_alloc_sg(host->max_segs, &ret);
+               ret = mmc_queue_alloc_sgs(mq, host->max_segs);
                if (ret)
                        goto cleanup_queue;
        }