/* Remove those ccw requests from the queue that need to be returned to the upper layer.  */
static void __dasd_device_process_ccw_queue(struct dasd_device *device, struct list_head *final_queue)
/* Remove those ccw requests from the queue that need to be returned to the upper layer.  */
static void __dasd_device_process_ccw_queue(struct dasd_device *device, struct list_head *final_queue)
{
	struct list_head *l, *n;
	struct dasd_ccw_req *cqr;
	list_for_each_safe(l, n, &device->ccw_queue) {
		cqr = list_entry(l, struct dasd_ccw_req, devlist);
		if (cqr->status == DASD_CQR_QUEUED ||
		    cqr->status == DASD_CQR_IN_IO ||
		    cqr->status == DASD_CQR_CLEAR_PENDING)
			break;
		if (cqr->status == DASD_CQR_ERROR) {
			__dasd_device_recovery(device, cqr);
		}
		list_move_tail(&cqr->devlist, final_queue);
	}
}