Skip to content

Commit

Permalink
[media] vb2: stop_streaming should return void
Browse files Browse the repository at this point in the history
The vb2 core ignores any return code from the stop_streaming op.
And there really isn't anything it can do anyway in case of an error.
So change the return type to void and update any drivers that implement it.

The int return gave drivers the idea that this operation could actually
fail, but that's really not the case.

The pwc amd sdr-msi3101 drivers both had this construction:

        if (mutex_lock_interruptible(&s->v4l2_lock))
                return -ERESTARTSYS;

This has been updated to just call mutex_lock(). The stop_streaming op
expects this to really stop streaming and I very much doubt this will
work reliably if stop_streaming just returns without really stopping the
DMA.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Pawel Osciak <pawel@osciak.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Apr 23, 2014
1 parent ac9687a commit e37559b
Show file tree
Hide file tree
Showing 41 changed files with 69 additions and 128 deletions.
3 changes: 1 addition & 2 deletions Documentation/video4linux/v4l2-pci-skeleton.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,14 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
* Stop the DMA engine. Any remaining buffers in the DMA queue are dequeued
* and passed on to the vb2 framework marked as STATE_ERROR.
*/
static int stop_streaming(struct vb2_queue *vq)
static void stop_streaming(struct vb2_queue *vq)
{
struct skeleton *skel = vb2_get_drv_priv(vq);

/* TODO: stop DMA */

/* Release all active buffers */
return_all_buffers(skel, VB2_BUF_STATE_ERROR);
return 0;
}

/*
Expand Down
3 changes: 1 addition & 2 deletions drivers/media/pci/sta2x11/sta2x11_vip.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
}

/* abort streaming and wait for last buffer */
static int stop_streaming(struct vb2_queue *vq)
static void stop_streaming(struct vb2_queue *vq)
{
struct sta2x11_vip *vip = vb2_get_drv_priv(vq);
struct vip_buffer *vip_buf, *node;
Expand All @@ -374,7 +374,6 @@ static int stop_streaming(struct vb2_queue *vq)
list_del(&vip_buf->list);
}
spin_unlock(&vip->lock);
return 0;
}

static struct vb2_ops vip_video_qops = {
Expand Down
3 changes: 1 addition & 2 deletions drivers/media/platform/blackfin/bfin_capture.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ static int bcap_start_streaming(struct vb2_queue *vq, unsigned int count)
return 0;
}

static int bcap_stop_streaming(struct vb2_queue *vq)
static void bcap_stop_streaming(struct vb2_queue *vq)
{
struct bcap_device *bcap_dev = vb2_get_drv_priv(vq);
struct ppi_if *ppi = bcap_dev->ppi;
Expand All @@ -452,7 +452,6 @@ static int bcap_stop_streaming(struct vb2_queue *vq)
list_del(&bcap_dev->cur_frm->list);
vb2_buffer_done(&bcap_dev->cur_frm->vb, VB2_BUF_STATE_ERROR);
}
return 0;
}

static struct vb2_ops bcap_video_qops = {
Expand Down
4 changes: 1 addition & 3 deletions drivers/media/platform/coda.c
Original file line number Diff line number Diff line change
Expand Up @@ -2269,7 +2269,7 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count)
return ret;
}

static int coda_stop_streaming(struct vb2_queue *q)
static void coda_stop_streaming(struct vb2_queue *q)
{
struct coda_ctx *ctx = vb2_get_drv_priv(q);
struct coda_dev *dev = ctx->dev;
Expand All @@ -2295,8 +2295,6 @@ static int coda_stop_streaming(struct vb2_queue *q)
ctx->bitstream.vaddr, ctx->bitstream.size);
ctx->runcounter = 0;
}

return 0;
}

static struct vb2_ops coda_qops = {
Expand Down
5 changes: 2 additions & 3 deletions drivers/media/platform/davinci/vpbe_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,15 +368,15 @@ static int vpbe_start_streaming(struct vb2_queue *vq, unsigned int count)
return ret;
}

static int vpbe_stop_streaming(struct vb2_queue *vq)
static void vpbe_stop_streaming(struct vb2_queue *vq)
{
struct vpbe_fh *fh = vb2_get_drv_priv(vq);
struct vpbe_layer *layer = fh->layer;
struct vpbe_display *disp = fh->disp_dev;
unsigned long flags;

if (!vb2_is_streaming(vq))
return 0;
return;

/* release all active buffers */
spin_lock_irqsave(&disp->dma_queue_lock, flags);
Expand All @@ -398,7 +398,6 @@ static int vpbe_stop_streaming(struct vb2_queue *vq)
vb2_buffer_done(&layer->next_frm->vb, VB2_BUF_STATE_ERROR);
}
spin_unlock_irqrestore(&disp->dma_queue_lock, flags);
return 0;
}

static struct vb2_ops video_qops = {
Expand Down
6 changes: 2 additions & 4 deletions drivers/media/platform/davinci/vpif_capture.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,15 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count)
}

/* abort streaming and wait for last buffer */
static int vpif_stop_streaming(struct vb2_queue *vq)
static void vpif_stop_streaming(struct vb2_queue *vq)
{
struct vpif_fh *fh = vb2_get_drv_priv(vq);
struct channel_obj *ch = fh->channel;
struct common_obj *common;
unsigned long flags;

if (!vb2_is_streaming(vq))
return 0;
return;

common = &ch->common[VPIF_VIDEO_INDEX];

Expand Down Expand Up @@ -390,8 +390,6 @@ static int vpif_stop_streaming(struct vb2_queue *vq)
vb2_buffer_done(&common->next_frm->vb, VB2_BUF_STATE_ERROR);
}
spin_unlock_irqrestore(&common->irqlock, flags);

return 0;
}

static struct vb2_ops video_qops = {
Expand Down
6 changes: 2 additions & 4 deletions drivers/media/platform/davinci/vpif_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,15 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count)
}

/* abort streaming and wait for last buffer */
static int vpif_stop_streaming(struct vb2_queue *vq)
static void vpif_stop_streaming(struct vb2_queue *vq)
{
struct vpif_fh *fh = vb2_get_drv_priv(vq);
struct channel_obj *ch = fh->channel;
struct common_obj *common;
unsigned long flags;

if (!vb2_is_streaming(vq))
return 0;
return;

common = &ch->common[VPIF_VIDEO_INDEX];

Expand Down Expand Up @@ -352,8 +352,6 @@ static int vpif_stop_streaming(struct vb2_queue *vq)
vb2_buffer_done(&common->next_frm->vb, VB2_BUF_STATE_ERROR);
}
spin_unlock_irqrestore(&common->irqlock, flags);

return 0;
}

static struct vb2_ops video_qops = {
Expand Down
4 changes: 1 addition & 3 deletions drivers/media/platform/exynos-gsc/gsc-m2m.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,13 @@ static int gsc_m2m_start_streaming(struct vb2_queue *q, unsigned int count)
return ret > 0 ? 0 : ret;
}

static int gsc_m2m_stop_streaming(struct vb2_queue *q)
static void gsc_m2m_stop_streaming(struct vb2_queue *q)
{
struct gsc_ctx *ctx = q->drv_priv;

__gsc_m2m_job_abort(ctx);

pm_runtime_put(&ctx->gsc_dev->pdev->dev);

return 0;
}

void gsc_m2m_job_finish(struct gsc_ctx *ctx, int vb_state)
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/platform/exynos4-is/fimc-capture.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,15 +294,15 @@ static int start_streaming(struct vb2_queue *q, unsigned int count)
return 0;
}

static int stop_streaming(struct vb2_queue *q)
static void stop_streaming(struct vb2_queue *q)
{
struct fimc_ctx *ctx = q->drv_priv;
struct fimc_dev *fimc = ctx->fimc_dev;

if (!fimc_capture_active(fimc))
return -EINVAL;
return;

return fimc_stop_capture(fimc, false);
fimc_stop_capture(fimc, false);
}

int fimc_capture_suspend(struct fimc_dev *fimc)
Expand Down
5 changes: 2 additions & 3 deletions drivers/media/platform/exynos4-is/fimc-isp-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static int isp_video_capture_start_streaming(struct vb2_queue *q,
return ret;
}

static int isp_video_capture_stop_streaming(struct vb2_queue *q)
static void isp_video_capture_stop_streaming(struct vb2_queue *q)
{
struct fimc_isp *isp = vb2_get_drv_priv(q);
struct fimc_is *is = fimc_isp_to_is(isp);
Expand All @@ -134,7 +134,7 @@ static int isp_video_capture_stop_streaming(struct vb2_queue *q)

ret = fimc_pipeline_call(&isp->video_capture.ve, set_stream, 0);
if (ret < 0)
return ret;
return;

dma->cmd = DMA_OUTPUT_COMMAND_DISABLE;
dma->notify_dma_done = DMA_OUTPUT_NOTIFY_DMA_DONE_DISABLE;
Expand All @@ -155,7 +155,6 @@ static int isp_video_capture_stop_streaming(struct vb2_queue *q)
clear_bit(ST_ISP_VID_CAP_STREAMING, &isp->state);

isp->video_capture.buf_count = 0;
return 0;
}

static int isp_video_capture_buffer_prepare(struct vb2_buffer *vb)
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/platform/exynos4-is/fimc-lite.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,14 +350,14 @@ static int start_streaming(struct vb2_queue *q, unsigned int count)
return 0;
}

static int stop_streaming(struct vb2_queue *q)
static void stop_streaming(struct vb2_queue *q)
{
struct fimc_lite *fimc = q->drv_priv;

if (!fimc_lite_active(fimc))
return -EINVAL;
return;

return fimc_lite_stop_capture(fimc, false);
fimc_lite_stop_capture(fimc, false);
}

static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *pfmt,
Expand Down
3 changes: 1 addition & 2 deletions drivers/media/platform/exynos4-is/fimc-m2m.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static int start_streaming(struct vb2_queue *q, unsigned int count)
return ret > 0 ? 0 : ret;
}

static int stop_streaming(struct vb2_queue *q)
static void stop_streaming(struct vb2_queue *q)
{
struct fimc_ctx *ctx = q->drv_priv;
int ret;
Expand All @@ -95,7 +95,6 @@ static int stop_streaming(struct vb2_queue *q)
fimc_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR);

pm_runtime_put(&ctx->fimc_dev->pdev->dev);
return 0;
}

static void fimc_device_run(void *priv)
Expand Down
7 changes: 3 additions & 4 deletions drivers/media/platform/marvell-ccic/mcam-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1156,18 +1156,18 @@ static int mcam_vb_start_streaming(struct vb2_queue *vq, unsigned int count)
return mcam_read_setup(cam);
}

static int mcam_vb_stop_streaming(struct vb2_queue *vq)
static void mcam_vb_stop_streaming(struct vb2_queue *vq)
{
struct mcam_camera *cam = vb2_get_drv_priv(vq);
unsigned long flags;

if (cam->state == S_BUFWAIT) {
/* They never gave us buffers */
cam->state = S_IDLE;
return 0;
return;
}
if (cam->state != S_STREAMING)
return -EINVAL;
return;
mcam_ctlr_stop_dma(cam);
/*
* Reset the CCIC PHY after stopping streaming,
Expand All @@ -1182,7 +1182,6 @@ static int mcam_vb_stop_streaming(struct vb2_queue *vq)
spin_lock_irqsave(&cam->dev_lock, flags);
INIT_LIST_HEAD(&cam->buffers);
spin_unlock_irqrestore(&cam->dev_lock, flags);
return 0;
}


Expand Down
5 changes: 2 additions & 3 deletions drivers/media/platform/mem2mem_testdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ static int m2mtest_start_streaming(struct vb2_queue *q, unsigned count)
return 0;
}

static int m2mtest_stop_streaming(struct vb2_queue *q)
static void m2mtest_stop_streaming(struct vb2_queue *q)
{
struct m2mtest_ctx *ctx = vb2_get_drv_priv(q);
struct vb2_buffer *vb;
Expand All @@ -799,12 +799,11 @@ static int m2mtest_stop_streaming(struct vb2_queue *q)
else
vb = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
if (vb == NULL)
return 0;
return;
spin_lock_irqsave(&ctx->dev->irqlock, flags);
v4l2_m2m_buf_done(vb, VB2_BUF_STATE_ERROR);
spin_unlock_irqrestore(&ctx->dev->irqlock, flags);
}
return 0;
}

static struct vb2_ops m2mtest_qops = {
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/platform/s3c-camif/camif-capture.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,10 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
return 0;
}

static int stop_streaming(struct vb2_queue *vq)
static void stop_streaming(struct vb2_queue *vq)
{
struct camif_vp *vp = vb2_get_drv_priv(vq);
return camif_stop_capture(vp);
camif_stop_capture(vp);
}

static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *pfmt,
Expand Down
4 changes: 1 addition & 3 deletions drivers/media/platform/s5p-jpeg/jpeg-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1670,13 +1670,11 @@ static int s5p_jpeg_start_streaming(struct vb2_queue *q, unsigned int count)
return ret > 0 ? 0 : ret;
}

static int s5p_jpeg_stop_streaming(struct vb2_queue *q)
static void s5p_jpeg_stop_streaming(struct vb2_queue *q)
{
struct s5p_jpeg_ctx *ctx = vb2_get_drv_priv(q);

pm_runtime_put(ctx->jpeg->dev);

return 0;
}

static struct vb2_ops s5p_jpeg_qops = {
Expand Down
3 changes: 1 addition & 2 deletions drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ static int s5p_mfc_start_streaming(struct vb2_queue *q, unsigned int count)
return 0;
}

static int s5p_mfc_stop_streaming(struct vb2_queue *q)
static void s5p_mfc_stop_streaming(struct vb2_queue *q)
{
unsigned long flags;
struct s5p_mfc_ctx *ctx = fh_to_ctx(q->drv_priv);
Expand Down Expand Up @@ -1071,7 +1071,6 @@ static int s5p_mfc_stop_streaming(struct vb2_queue *q)
}
if (aborted)
ctx->state = MFCINST_RUNNING;
return 0;
}


Expand Down
3 changes: 1 addition & 2 deletions drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1954,7 +1954,7 @@ static int s5p_mfc_start_streaming(struct vb2_queue *q, unsigned int count)
return 0;
}

static int s5p_mfc_stop_streaming(struct vb2_queue *q)
static void s5p_mfc_stop_streaming(struct vb2_queue *q)
{
unsigned long flags;
struct s5p_mfc_ctx *ctx = fh_to_ctx(q->drv_priv);
Expand Down Expand Up @@ -1983,7 +1983,6 @@ static int s5p_mfc_stop_streaming(struct vb2_queue *q)
ctx->src_queue_cnt = 0;
}
spin_unlock_irqrestore(&dev->irqlock, flags);
return 0;
}

static void s5p_mfc_buf_queue(struct vb2_buffer *vb)
Expand Down
3 changes: 1 addition & 2 deletions drivers/media/platform/s5p-tv/mixer_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ static void mxr_watchdog(unsigned long arg)
spin_unlock_irqrestore(&layer->enq_slock, flags);
}

static int stop_streaming(struct vb2_queue *vq)
static void stop_streaming(struct vb2_queue *vq)
{
struct mxr_layer *layer = vb2_get_drv_priv(vq);
struct mxr_device *mdev = layer->mdev;
Expand Down Expand Up @@ -1031,7 +1031,6 @@ static int stop_streaming(struct vb2_queue *vq)
mxr_streamer_put(mdev);
/* allow changes in output configuration */
mxr_output_put(mdev);
return 0;
}

static struct vb2_ops mxr_video_qops = {
Expand Down
Loading

0 comments on commit e37559b

Please sign in to comment.