/* We are guaranteeing that the request queue will be goosed at some point during this call. Notes: If cmd was requeued, upon return it will be a stale pointer.  */
static struct scsi_cmnd* scsi_end_request(struct scsi_cmnd *cmd, int error, int bytes, int requeue)
/* We are guaranteeing that the request queue will be goosed at some point during this call. Notes: If cmd was requeued, upon return it will be a stale pointer.  */
static struct scsi_cmnd* scsi_end_request(struct scsi_cmnd *cmd, int error, int bytes, int requeue)
{
	struct request_queue *q = cmd->device->request_queue;
	struct request *req = cmd->request;
	if (blk_end_request(req, error, bytes)) {
		if (error && scsi_noretry_cmd(cmd))
			blk_end_request_all(req, error);
		else {
			if (requeue) {
				scsi_release_buffers(cmd);
				scsi_requeue_command(q, cmd);
				cmd = NULL;
			}
			return cmd;
		}
	}
	__scsi_release_buffers(cmd, 0);
	scsi_next_command(cmd);
	return NULL;
}