Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: queue: Factor out mmc_queue_alloc_sgs()

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>

authored by

Adrian Hunter and committed by
Ulf Hansson
64e29e42 f2b8b522

+16 -6
+16 -6
drivers/mmc/card/queue.c
··· 237 237 } 238 238 #endif 239 239 240 + static int mmc_queue_alloc_sgs(struct mmc_queue *mq, int max_segs) 241 + { 242 + struct mmc_queue_req *mqrq_cur = mq->mqrq_cur; 243 + struct mmc_queue_req *mqrq_prev = mq->mqrq_prev; 244 + int ret; 245 + 246 + mqrq_cur->sg = mmc_alloc_sg(max_segs, &ret); 247 + if (ret) 248 + return ret; 249 + 250 + mqrq_prev->sg = mmc_alloc_sg(max_segs, &ret); 251 + 252 + return ret; 253 + } 254 + 240 255 /** 241 256 * mmc_init_queue - initialise a queue structure. 242 257 * @mq: mmc queue ··· 324 309 blk_queue_max_segments(mq->queue, host->max_segs); 325 310 blk_queue_max_segment_size(mq->queue, host->max_seg_size); 326 311 327 - mqrq_cur->sg = mmc_alloc_sg(host->max_segs, &ret); 328 - if (ret) 329 - goto cleanup_queue; 330 - 331 - 332 - mqrq_prev->sg = mmc_alloc_sg(host->max_segs, &ret); 312 + ret = mmc_queue_alloc_sgs(mq, host->max_segs); 333 313 if (ret) 334 314 goto cleanup_queue; 335 315 }