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_bounce_sgs()

In preparation for supporting a queue of requests, factor out
mmc_queue_alloc_bounce_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>
[Ulf: Fixed compiler warning]
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Adrian Hunter and committed by
Ulf Hansson
f2b8b522 c853982e

+28 -16
+28 -16
drivers/mmc/card/queue.c
··· 211 211 212 212 return true; 213 213 } 214 + 215 + static int mmc_queue_alloc_bounce_sgs(struct mmc_queue *mq, 216 + unsigned int bouncesz) 217 + { 218 + struct mmc_queue_req *mqrq_cur = mq->mqrq_cur; 219 + struct mmc_queue_req *mqrq_prev = mq->mqrq_prev; 220 + int ret; 221 + 222 + mqrq_cur->sg = mmc_alloc_sg(1, &ret); 223 + if (ret) 224 + return ret; 225 + 226 + mqrq_cur->bounce_sg = mmc_alloc_sg(bouncesz / 512, &ret); 227 + if (ret) 228 + return ret; 229 + 230 + mqrq_prev->sg = mmc_alloc_sg(1, &ret); 231 + if (ret) 232 + return ret; 233 + 234 + mqrq_prev->bounce_sg = mmc_alloc_sg(bouncesz / 512, &ret); 235 + 236 + return ret; 237 + } 214 238 #endif 215 239 216 240 /** ··· 251 227 { 252 228 struct mmc_host *host = card->host; 253 229 u64 limit = BLK_BOUNCE_HIGH; 230 + bool bounce = false; 254 231 int ret; 255 232 struct mmc_queue_req *mqrq_cur = &mq->mqrq[0]; 256 233 struct mmc_queue_req *mqrq_prev = &mq->mqrq[1]; ··· 294 269 blk_queue_max_segments(mq->queue, bouncesz / 512); 295 270 blk_queue_max_segment_size(mq->queue, bouncesz); 296 271 297 - mqrq_cur->sg = mmc_alloc_sg(1, &ret); 272 + ret = mmc_queue_alloc_bounce_sgs(mq, bouncesz); 298 273 if (ret) 299 274 goto cleanup_queue; 300 - 301 - mqrq_cur->bounce_sg = 302 - mmc_alloc_sg(bouncesz / 512, &ret); 303 - if (ret) 304 - goto cleanup_queue; 305 - 306 - mqrq_prev->sg = mmc_alloc_sg(1, &ret); 307 - if (ret) 308 - goto cleanup_queue; 309 - 310 - mqrq_prev->bounce_sg = 311 - mmc_alloc_sg(bouncesz / 512, &ret); 312 - if (ret) 313 - goto cleanup_queue; 275 + bounce = true; 314 276 } 315 277 } 316 278 #endif 317 279 318 - if (!mqrq_cur->bounce_buf && !mqrq_prev->bounce_buf) { 280 + if (!bounce) { 319 281 blk_queue_bounce_limit(mq->queue, limit); 320 282 blk_queue_max_hw_sectors(mq->queue, 321 283 min(host->max_blk_count, host->max_req_size / 512));