#define BLK_MQ_RESOURCE_DELAY  3               /* ms units */
 
+static void blk_mq_handle_dev_resource(struct request *rq,
+                                      struct list_head *list)
+{
+       struct request *next =
+               list_first_entry_or_null(list, struct request, queuelist);
+
+       /*
+        * If an I/O scheduler has been configured and we got a driver tag for
+        * the next request already, free it.
+        */
+       if (next)
+               blk_mq_put_driver_tag(next);
+
+       list_add(&rq->queuelist, list);
+       __blk_mq_requeue_request(rq);
+}
+
 /*
  * Returns true if we did some work AND can potentially do more.
  */
 
                ret = q->mq_ops->queue_rq(hctx, &bd);
                if (ret == BLK_STS_RESOURCE || ret == BLK_STS_DEV_RESOURCE) {
-                       /*
-                        * If an I/O scheduler has been configured and we got a
-                        * driver tag for the next request already, free it
-                        * again.
-                        */
-                       if (!list_empty(list)) {
-                               nxt = list_first_entry(list, struct request, queuelist);
-                               blk_mq_put_driver_tag(nxt);
-                       }
-                       list_add(&rq->queuelist, list);
-                       __blk_mq_requeue_request(rq);
+                       blk_mq_handle_dev_resource(rq, list);
                        break;
                }