* create_bufs is called with count == 0, but count == 0 should still
         * do the memory and type validation.
         */
-       if (q->fileio) {
+       if (vb2_fileio_is_active(q)) {
                dprintk(1, "file io in progress\n");
                return -EBUSY;
        }
        struct vb2_buffer *vb;
        int ret;
 
-       if (q->fileio) {
+       if (vb2_fileio_is_active(q)) {
                dprintk(1, "file io in progress\n");
                return -EBUSY;
        }
  */
 int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
 {
-       if (q->fileio) {
+       if (vb2_fileio_is_active(q)) {
                dprintk(1, "file io in progress\n");
                return -EBUSY;
        }
  */
 int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking)
 {
-       if (q->fileio) {
+       if (vb2_fileio_is_active(q)) {
                dprintk(1, "file io in progress\n");
                return -EBUSY;
        }
  */
 int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type)
 {
-       if (q->fileio) {
+       if (vb2_fileio_is_active(q)) {
                dprintk(1, "file io in progress\n");
                return -EBUSY;
        }
  */
 int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type)
 {
-       if (q->fileio) {
+       if (vb2_fileio_is_active(q)) {
                dprintk(1, "file io in progress\n");
                return -EBUSY;
        }
                return -EINVAL;
        }
 
+       if (vb2_fileio_is_active(q)) {
+               dprintk(1, "expbuf: file io in progress\n");
+               return -EBUSY;
+       }
+
        vb_plane = &vb->planes[eb->plane];
 
        dbuf = call_ptr_memop(vb, get_dmabuf, vb_plane->mem_priv, eb->flags & O_ACCMODE);
                        return -EINVAL;
                }
        }
+       if (vb2_fileio_is_active(q)) {
+               dprintk(1, "mmap: file io in progress\n");
+               return -EBUSY;
+       }
 
        /*
         * Find the plane corresponding to the offset passed by userspace.
        /*
         * Start file I/O emulator only if streaming API has not been used yet.
         */
-       if (q->num_buffers == 0 && q->fileio == NULL) {
+       if (q->num_buffers == 0 && !vb2_fileio_is_active(q)) {
                if (!V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_READ) &&
                                (req_events & (POLLIN | POLLRDNORM))) {
                        if (__vb2_init_fileio(q, 1))
        fileio->req.count = count;
        fileio->req.memory = V4L2_MEMORY_MMAP;
        fileio->req.type = q->type;
-       ret = vb2_reqbufs(q, &fileio->req);
+       q->fileio = fileio;
+       ret = __reqbufs(q, &fileio->req);
        if (ret)
                goto err_kfree;
 
                        b->type = q->type;
                        b->memory = q->memory;
                        b->index = i;
-                       ret = vb2_qbuf(q, b);
+                       ret = vb2_internal_qbuf(q, b);
                        if (ret)
                                goto err_reqbufs;
                        fileio->bufs[i].queued = 1;
        /*
         * Start streaming.
         */
-       ret = vb2_streamon(q, q->type);
+       ret = vb2_internal_streamon(q, q->type);
        if (ret)
                goto err_reqbufs;
 
-       q->fileio = fileio;
-
        return ret;
 
 err_reqbufs:
        fileio->req.count = 0;
-       vb2_reqbufs(q, &fileio->req);
+       __reqbufs(q, &fileio->req);
 
 err_kfree:
+       q->fileio = NULL;
        kfree(fileio);
        return ret;
 }
        /*
         * Initialize emulator on first call.
         */
-       if (!q->fileio) {
+       if (!vb2_fileio_is_active(q)) {
                ret = __vb2_init_fileio(q, read);
                dprintk(3, "vb2_init_fileio result: %d\n", ret);
                if (ret)
 
        /* Try to be smart: only lock if polling might start fileio,
           otherwise locking will only introduce unwanted delays. */
-       if (q->num_buffers == 0 && q->fileio == NULL) {
+       if (q->num_buffers == 0 && !vb2_fileio_is_active(q)) {
                if (!V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_READ) &&
                                (req_events & (POLLIN | POLLRDNORM)))
                        must_lock = true;