/* Note: This routine adjusts max_hw_segments to make room for appending the drain buffer. If you call blk_queue_max_hw_segments() or blk_queue_max_phys_segments() after calling this routine, you must set the limit to one fewer than your device can support otherwise there won't be room for the drain buffer.  */
int blk_queue_dma_drain(struct request_queue *q, dma_drain_needed_fn *dma_drain_needed, void *buf, unsigned int size)
/* Note: This routine adjusts max_hw_segments to make room for appending the drain buffer. If you call blk_queue_max_hw_segments() or blk_queue_max_phys_segments() after calling this routine, you must set the limit to one fewer than your device can support otherwise there won't be room for the drain buffer.  */
int blk_queue_dma_drain(struct request_queue *q, dma_drain_needed_fn *dma_drain_needed, void *buf, unsigned int size)
{
	if (queue_max_hw_segments(q) < 2 || queue_max_phys_segments(q) < 2)
		return -EINVAL;
	blk_queue_max_hw_segments(q, queue_max_hw_segments(q) - 1);
	blk_queue_max_phys_segments(q, queue_max_phys_segments(q) - 1);
	q->dma_drain_needed = dma_drain_needed;
	q->dma_drain_buffer = buf;
	q->dma_drain_size = size;
	return 0;
}