From 8c47ada09b7cfc59ddc67c806b7a536014146cc8 Mon Sep 17 00:00:00 2001 From: Sunyoung Kang Date: Tue, 3 Jul 2018 13:43:12 +0900 Subject: [PATCH] [COMMON] media: mfc: DRV4.0: remove unnecessary code over all This removes the NULL check for data already identified like mfc_dev, mfc_ctx over all. Change-Id: Ibdc7ad039a8f1d6feccfe3954a1c42ba1bed9895 Signed-off-by: Sunyoung Kang --- .../media/platform/exynos/mfc/mfc_dec_v4l2.c | 62 +------ .../media/platform/exynos/mfc/mfc_dec_vb2.c | 159 ++---------------- .../media/platform/exynos/mfc/mfc_enc_vb2.c | 8 +- .../media/platform/exynos/mfc/mfc_hwlock.c | 156 ++--------------- .../media/platform/exynos/mfc/mfc_hwlock.h | 4 +- drivers/media/platform/exynos/mfc/mfc_isr.c | 13 +- drivers/media/platform/exynos/mfc/mfc_nal_q.c | 129 +------------- drivers/media/platform/exynos/mfc/mfc_otf.c | 15 +- .../media/platform/exynos/mfc/mfc_reg_api.c | 39 +---- drivers/media/platform/exynos/mfc/mfc_sync.c | 15 -- drivers/media/platform/exynos/mfc/mfc_utils.c | 25 +-- 11 files changed, 53 insertions(+), 572 deletions(-) diff --git a/drivers/media/platform/exynos/mfc/mfc_dec_v4l2.c b/drivers/media/platform/exynos/mfc/mfc_dec_v4l2.c index 99798edeee1a..70d082cecadf 100644 --- a/drivers/media/platform/exynos/mfc/mfc_dec_v4l2.c +++ b/drivers/media/platform/exynos/mfc/mfc_dec_v4l2.c @@ -272,19 +272,13 @@ static int mfc_dec_g_fmt_vid_cap_mplane(struct file *file, void *priv, struct v4l2_format *f) { struct mfc_ctx *ctx = fh_to_mfc_ctx(file->private_data); - struct mfc_dec *dec; + struct mfc_dec *dec = ctx->dec_priv; struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp; struct mfc_raw_info *raw; int i; mfc_debug_enter(); - dec = ctx->dec_priv; - if (!dec) { - mfc_err_dev("no mfc decoder to run\n"); - return -EINVAL; - } - mfc_debug(2, "dec dst g_fmt, state: %d\n", ctx->state); if (ctx->state == MFCINST_GOT_INST || @@ -368,17 +362,11 @@ static int mfc_dec_g_fmt_vid_out_mplane(struct file *file, void *priv, struct v4l2_format *f) { struct mfc_ctx *ctx = fh_to_mfc_ctx(file->private_data); - struct mfc_dec *dec; + struct mfc_dec *dec = ctx->dec_priv; struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp; mfc_debug_enter(); - dec = ctx->dec_priv; - if (!dec) { - mfc_err_dev("no mfc decoder to run\n"); - return -EINVAL; - } - mfc_debug(4, "dec src g_fmt, state: %d\n", ctx->state); /* This is run on OUTPUT @@ -573,22 +561,12 @@ static int mfc_dec_reqbufs(struct file *file, void *priv, { struct mfc_dev *dev = video_drvdata(file); struct mfc_ctx *ctx = fh_to_mfc_ctx(file->private_data); - struct mfc_dec *dec; + struct mfc_dec *dec = ctx->dec_priv; + int ret = 0; mfc_debug_enter(); - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return -EINVAL; - } - - dec = ctx->dec_priv; - if (!dec) { - mfc_err_dev("no mfc decoder to run\n"); - return -EINVAL; - } - if (reqbufs->memory == V4L2_MEMORY_MMAP) { mfc_err_ctx("Not supported memory type (%d)\n", reqbufs->memory); return -EINVAL; @@ -895,26 +873,11 @@ static int __mfc_dec_ext_info(struct mfc_ctx *ctx) /* Get ctrl */ static int __mfc_dec_get_ctrl_val(struct mfc_ctx *ctx, struct v4l2_control *ctrl) { - struct mfc_dev *dev; - struct mfc_dec *dec; + struct mfc_dev *dev = ctx->dev; + struct mfc_dec *dec = ctx->dec_priv; struct mfc_ctx_ctrl *ctx_ctrl; int found = 0; - if (!ctx) { - mfc_err_dev("no mfc context to run\n"); - return -EINVAL; - } - dev = ctx->dev; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return -EINVAL; - } - dec = ctx->dec_priv; - if (!dec) { - mfc_err_dev("no mfc decoder to run\n"); - return -EINVAL; - } - switch (ctrl->id) { case V4L2_CID_MPEG_VIDEO_DECODER_MPEG4_DEBLOCK_FILTER: ctrl->value = dec->loop_filter_mpeg4; @@ -1051,24 +1014,13 @@ static int mfc_dec_s_ctrl(struct file *file, void *priv, { struct mfc_dev *dev = video_drvdata(file); struct mfc_ctx *ctx = fh_to_mfc_ctx(file->private_data); - struct mfc_dec *dec; + struct mfc_dec *dec = ctx->dec_priv; struct mfc_ctx_ctrl *ctx_ctrl; int ret = 0; int found = 0; mfc_debug_enter(); - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return -EINVAL; - } - - dec = ctx->dec_priv; - if (!dec) { - mfc_err_dev("no mfc decoder to run\n"); - return -EINVAL; - } - ret = __mfc_dec_check_ctrl_val(ctx, ctrl); if (ret) return ret; diff --git a/drivers/media/platform/exynos/mfc/mfc_dec_vb2.c b/drivers/media/platform/exynos/mfc/mfc_dec_vb2.c index bc5bfcdbe8f5..6b849445a2ec 100644 --- a/drivers/media/platform/exynos/mfc/mfc_dec_vb2.c +++ b/drivers/media/platform/exynos/mfc/mfc_dec_vb2.c @@ -26,35 +26,14 @@ static int mfc_dec_queue_setup(struct vb2_queue *vq, unsigned int *buf_count, unsigned int *plane_count, unsigned int psize[], struct device *alloc_devs[]) { - struct mfc_ctx *ctx; - struct mfc_dev *dev; - struct mfc_dec *dec; + struct mfc_ctx *ctx = vq->drv_priv; + struct mfc_dev *dev = ctx->dev; + struct mfc_dec *dec = ctx->dec_priv; struct mfc_raw_info *raw; int i; mfc_debug_enter(); - if (!vq) { - mfc_err_dev("no vb2_queue info\n"); - return -EINVAL; - } - - ctx = vq->drv_priv; - if (!ctx) { - mfc_err_dev("no mfc context to run\n"); - return -EINVAL; - } - dev = ctx->dev; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return -EINVAL; - } - dec = ctx->dec_priv; - if (!dec) { - mfc_err_dev("no mfc decoder to run\n"); - return -EINVAL; - } - raw = &ctx->raw_buf; /* Video output for decoding (source) @@ -112,17 +91,7 @@ static int mfc_dec_queue_setup(struct vb2_queue *vq, static void mfc_dec_unlock(struct vb2_queue *q) { struct mfc_ctx *ctx = q->drv_priv; - struct mfc_dev *dev; - - if (!ctx) { - mfc_err_dev("no mfc context to run\n"); - return; - } - dev = ctx->dev; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return; - } + struct mfc_dev *dev = ctx->dev; mutex_unlock(&dev->mfc_mutex); } @@ -130,17 +99,7 @@ static void mfc_dec_unlock(struct vb2_queue *q) static void mfc_dec_lock(struct vb2_queue *q) { struct mfc_ctx *ctx = q->drv_priv; - struct mfc_dev *dev; - - if (!ctx) { - mfc_err_dev("no mfc context to run\n"); - return; - } - dev = ctx->dev; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return; - } + struct mfc_dev *dev = ctx->dev; mutex_lock(&dev->mfc_mutex); } @@ -149,27 +108,13 @@ static int mfc_dec_buf_init(struct vb2_buffer *vb) { struct vb2_queue *vq = vb->vb2_queue; struct mfc_ctx *ctx = vq->drv_priv; - struct mfc_dev *dev; - struct mfc_dec *dec; + struct mfc_dev *dev = ctx->dev; + struct mfc_dec *dec = ctx->dec_priv; struct mfc_buf *buf = vb_to_mfc_buf(vb); dma_addr_t start_raw; int i, ret; mfc_debug_enter(); - if (!ctx) { - mfc_err_dev("no mfc context to run\n"); - return -EINVAL; - } - dev = ctx->dev; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return -EINVAL; - } - dec = ctx->dec_priv; - if (!dec) { - mfc_err_dev("no mfc decoder to run\n"); - return -EINVAL; - } if (vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { ret = mfc_check_vb_with_fmt(ctx->dst_fmt, vb); @@ -227,21 +172,12 @@ static int mfc_dec_buf_prepare(struct vb2_buffer *vb) { struct vb2_queue *vq = vb->vb2_queue; struct mfc_ctx *ctx = vq->drv_priv; - struct mfc_dec *dec; + struct mfc_dec *dec = ctx->dec_priv; struct mfc_raw_info *raw; unsigned int index = vb->index; size_t buf_size; int i; - if (!ctx) { - mfc_err_dev("no mfc context to run\n"); - return -EINVAL; - } - dec = ctx->dec_priv; - if (!dec) { - mfc_err_dev("no mfc decoder to run\n"); - return -EINVAL; - } if (vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { raw = &ctx->raw_buf; /* check the size per plane */ @@ -290,11 +226,6 @@ static void mfc_dec_buf_finish(struct vb2_buffer *vb) struct mfc_ctx *ctx = vq->drv_priv; unsigned int index = vb->index; - if (!ctx) { - mfc_err_dev("no mfc context to run\n"); - return; - } - if (vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { if (call_cop(ctx, to_ctx_ctrls, ctx, &ctx->dst_ctrls[index]) < 0) mfc_err_ctx("failed in to_ctx_ctrls\n"); @@ -311,10 +242,6 @@ static void mfc_dec_buf_cleanup(struct vb2_buffer *vb) unsigned int index = vb->index; mfc_debug_enter(); - if (!ctx) { - mfc_err_dev("no mfc context to run\n"); - return; - } if (vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { if (call_cop(ctx, cleanup_buf_ctrls, ctx, @@ -334,18 +261,7 @@ static void mfc_dec_buf_cleanup(struct vb2_buffer *vb) static int mfc_dec_start_streaming(struct vb2_queue *q, unsigned int count) { struct mfc_ctx *ctx = q->drv_priv; - struct mfc_dev *dev; - - if (!ctx) { - mfc_err_dev("no mfc context to run\n"); - return -EINVAL; - } - - dev = ctx->dev; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return -EINVAL; - } + struct mfc_dev *dev = ctx->dev; if (ctx->state == MFCINST_FINISHING) mfc_change_state(ctx, MFCINST_RUNNING); @@ -361,24 +277,12 @@ static int mfc_dec_start_streaming(struct vb2_queue *q, unsigned int count) static void __mfc_dec_src_stop_streaming(struct mfc_ctx *ctx) { - struct mfc_dev *dev; - struct mfc_dec *dec; + struct mfc_dev *dev = ctx->dev; + struct mfc_dec *dec = ctx->dec_priv; struct mfc_buf *src_mb; int index, csd, condition = 0; int ret = 0; - dev = ctx->dev; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return; - } - - dec = ctx->dec_priv; - if (!dec) { - mfc_err_dev("no mfc decoder to run\n"); - return; - } - while (1) { csd = mfc_check_buf_vb_flag(ctx, MFC_FLAG_CSD); @@ -439,15 +343,9 @@ static void __mfc_dec_src_stop_streaming(struct mfc_ctx *ctx) static void __mfc_dec_dst_stop_streaming(struct mfc_ctx *ctx) { - struct mfc_dec *dec; + struct mfc_dec *dec = ctx->dec_priv; int index = 0; - dec = ctx->dec_priv; - if (!dec) { - mfc_err_dev("no mfc decoder to run\n"); - return; - } - mfc_cleanup_assigned_fd(ctx); mfc_cleanup_queue(&ctx->buf_queue_lock, &ctx->ref_buf_queue); @@ -482,21 +380,10 @@ static void __mfc_dec_dst_stop_streaming(struct mfc_ctx *ctx) static void mfc_dec_stop_streaming(struct vb2_queue *q) { struct mfc_ctx *ctx = q->drv_priv; - struct mfc_dev *dev; + struct mfc_dev *dev = ctx->dev; int ret = 0; int prev_state; - if (!ctx) { - mfc_err_dev("no mfc context to run\n"); - return; - } - - dev = ctx->dev; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return; - } - mfc_info_ctx("dec stop_streaming is called, hwlock : %d, type : %d\n", test_bit(ctx->num, &dev->hwlock.bits), q->type); MFC_TRACE_CTX("** DEC streamoff(type:%d)\n", q->type); @@ -555,29 +442,13 @@ static void mfc_dec_buf_queue(struct vb2_buffer *vb) { struct vb2_queue *vq = vb->vb2_queue; struct mfc_ctx *ctx = vq->drv_priv; - struct mfc_dev *dev; - struct mfc_dec *dec; + struct mfc_dev *dev = ctx->dev; + struct mfc_dec *dec = ctx->dec_priv; struct mfc_buf *buf = vb_to_mfc_buf(vb); int i; unsigned char *stream_vir = NULL; mfc_debug_enter(); - if (!ctx) { - mfc_err_dev("no mfc context to run\n"); - return; - } - - dev = ctx->dev; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return; - } - - dec = ctx->dec_priv; - if (!dec) { - mfc_err_dev("no mfc decoder to run\n"); - return; - } if (vq->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { mfc_debug(2, "[BUFINFO] ctx[%d] add src index:%d, addr: 0x%08llx\n", diff --git a/drivers/media/platform/exynos/mfc/mfc_enc_vb2.c b/drivers/media/platform/exynos/mfc/mfc_enc_vb2.c index f80fcc27d36d..75f0b4b23156 100644 --- a/drivers/media/platform/exynos/mfc/mfc_enc_vb2.c +++ b/drivers/media/platform/exynos/mfc/mfc_enc_vb2.c @@ -27,20 +27,14 @@ static int mfc_enc_queue_setup(struct vb2_queue *vq, unsigned int *buf_count, unsigned int *plane_count, unsigned int psize[], struct device *alloc_devs[]) { - struct mfc_dev *dev; struct mfc_ctx *ctx = vq->drv_priv; + struct mfc_dev *dev = ctx->dev; struct mfc_enc *enc = ctx->enc_priv; struct mfc_raw_info *raw; int i; mfc_debug_enter(); - dev = ctx->dev; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return -EINVAL; - } - if (ctx->state != MFCINST_GOT_INST && vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { mfc_err_ctx("invalid state: %d\n", ctx->state); diff --git a/drivers/media/platform/exynos/mfc/mfc_hwlock.c b/drivers/media/platform/exynos/mfc/mfc_hwlock.c index 69bb9727d011..44a1fc999197 100644 --- a/drivers/media/platform/exynos/mfc/mfc_hwlock.c +++ b/drivers/media/platform/exynos/mfc/mfc_hwlock.c @@ -36,11 +36,6 @@ void mfc_init_hwlock(struct mfc_dev *dev) { unsigned long flags; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return; - } - spin_lock_init(&dev->hwlock.lock); spin_lock_irqsave(&dev->hwlock.lock, flags); @@ -54,16 +49,10 @@ void mfc_init_hwlock(struct mfc_dev *dev) spin_unlock_irqrestore(&dev->hwlock.lock, flags); } -static int __mfc_remove_listable_wq_dev(struct mfc_dev *dev) +static void __mfc_remove_listable_wq_dev(struct mfc_dev *dev) { struct mfc_listable_wq *listable_wq; unsigned long flags; - int ret = -1; - - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return -EINVAL; - } spin_lock_irqsave(&dev->hwlock.lock, flags); __mfc_print_hwlock(dev); @@ -77,33 +66,18 @@ static int __mfc_remove_listable_wq_dev(struct mfc_dev *dev) list_del(&listable_wq->list); dev->hwlock.wl_count--; - ret = 0; break; } __mfc_print_hwlock(dev); spin_unlock_irqrestore(&dev->hwlock.lock, flags); - - return ret; } -static int __mfc_remove_listable_wq_ctx(struct mfc_ctx *curr_ctx) +static void __mfc_remove_listable_wq_ctx(struct mfc_ctx *curr_ctx) { - struct mfc_dev *dev; + struct mfc_dev *dev = curr_ctx->dev; struct mfc_listable_wq *listable_wq; unsigned long flags; - int ret = -1; - - if (!curr_ctx) { - mfc_err_dev("no mfc context to run\n"); - return -EINVAL; - } - - dev = curr_ctx->dev; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return -EINVAL; - } spin_lock_irqsave(&dev->hwlock.lock, flags); __mfc_print_hwlock(dev); @@ -117,15 +91,12 @@ static int __mfc_remove_listable_wq_ctx(struct mfc_ctx *curr_ctx) list_del(&listable_wq->list); dev->hwlock.wl_count--; - ret = 0; break; } } __mfc_print_hwlock(dev); spin_unlock_irqrestore(&dev->hwlock.lock, flags); - - return ret; } /* @@ -138,11 +109,6 @@ int mfc_get_hwlock_dev(struct mfc_dev *dev) int ret = 0; unsigned long flags; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return -EINVAL; - } - mutex_lock(&dev->hwlock_wq.wait_mutex); spin_lock_irqsave(&dev->hwlock.lock, flags); @@ -213,22 +179,11 @@ int mfc_get_hwlock_dev(struct mfc_dev *dev) */ int mfc_get_hwlock_ctx(struct mfc_ctx *curr_ctx) { - struct mfc_dev *dev; struct mfc_ctx *ctx = curr_ctx; + struct mfc_dev *dev = curr_ctx->dev; int ret = 0; unsigned long flags; - if (!curr_ctx) { - mfc_err_dev("no mfc context to run\n"); - return -EINVAL; - } - - dev = curr_ctx->dev; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return -EINVAL; - } - mutex_lock(&curr_ctx->hwlock_wq.wait_mutex); spin_lock_irqsave(&dev->hwlock.lock, flags); @@ -304,16 +259,10 @@ int mfc_get_hwlock_ctx(struct mfc_ctx *curr_ctx) * 1: succeeded to release hwlock, hwlock is captured by another module * -1: error since device is waiting again. */ -int mfc_release_hwlock_dev(struct mfc_dev *dev) +void mfc_release_hwlock_dev(struct mfc_dev *dev) { struct mfc_listable_wq *listable_wq; unsigned long flags; - int ret = -1; - - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return -EINVAL; - } spin_lock_irqsave(&dev->hwlock.lock, flags); __mfc_print_hwlock(dev); @@ -323,10 +272,8 @@ int mfc_release_hwlock_dev(struct mfc_dev *dev) if (dev->shutdown) { mfc_debug(2, "Couldn't wakeup module. Shutdown was called\n"); - ret = 0; } else if (list_empty(&dev->hwlock.waiting_list)) { mfc_debug(2, "No waiting module\n"); - ret = 0; } else { mfc_debug(2, "There is a waiting module\n"); listable_wq = list_entry(dev->hwlock.waiting_list.next, struct mfc_listable_wq, list); @@ -349,12 +296,10 @@ int mfc_release_hwlock_dev(struct mfc_dev *dev) dev->hwlock.wl_count, dev->hwlock.transfer_owner); wake_up(&listable_wq->wait_queue); - ret = 1; } __mfc_print_hwlock(dev); spin_unlock_irqrestore(&dev->hwlock.lock, flags); - return ret; } /* @@ -364,23 +309,11 @@ int mfc_release_hwlock_dev(struct mfc_dev *dev) * 0: succeeded to release hwlock * 1: succeeded to release hwlock, hwlock is captured by another module */ -static int __mfc_release_hwlock_ctx_protected(struct mfc_ctx *curr_ctx) +static void __mfc_release_hwlock_ctx_protected(struct mfc_ctx *curr_ctx) { - struct mfc_dev *dev; + struct mfc_dev *dev = curr_ctx->dev; struct mfc_ctx *ctx = curr_ctx; struct mfc_listable_wq *listable_wq; - int ret = -1; - - if (!curr_ctx) { - mfc_err_dev("no mfc context to run\n"); - return -EINVAL; - } - - dev = curr_ctx->dev; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return -EINVAL; - } __mfc_print_hwlock(dev); clear_bit(curr_ctx->num, &dev->hwlock.bits); @@ -388,10 +321,8 @@ static int __mfc_release_hwlock_ctx_protected(struct mfc_ctx *curr_ctx) if (dev->shutdown) { mfc_debug(2, "Couldn't wakeup module. Shutdown was called\n"); - ret = 0; } else if (list_empty(&dev->hwlock.waiting_list)) { mfc_debug(2, "No waiting module\n"); - ret = 0; } else { mfc_debug(2, "There is a waiting module\n"); listable_wq = list_entry(dev->hwlock.waiting_list.next, struct mfc_listable_wq, list); @@ -414,11 +345,9 @@ static int __mfc_release_hwlock_ctx_protected(struct mfc_ctx *curr_ctx) dev->hwlock.wl_count, dev->hwlock.transfer_owner); wake_up(&listable_wq->wait_queue); - ret = 1; } __mfc_print_hwlock(dev); - return ret; } /* @@ -426,43 +355,20 @@ static int __mfc_release_hwlock_ctx_protected(struct mfc_ctx *curr_ctx) * 0: succeeded to release hwlock * 1: succeeded to release hwlock, hwlock is captured by another module */ -int mfc_release_hwlock_ctx(struct mfc_ctx *curr_ctx) +void mfc_release_hwlock_ctx(struct mfc_ctx *curr_ctx) { - struct mfc_dev *dev; + struct mfc_dev *dev = curr_ctx->dev; unsigned long flags; - int ret = -1; - - if (!curr_ctx) { - mfc_err_dev("no mfc context to run\n"); - return -EINVAL; - } - - dev = curr_ctx->dev; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return -EINVAL; - } spin_lock_irqsave(&dev->hwlock.lock, flags); - ret = __mfc_release_hwlock_ctx_protected(curr_ctx); + __mfc_release_hwlock_ctx_protected(curr_ctx); spin_unlock_irqrestore(&dev->hwlock.lock, flags); - return ret; } -static inline int __mfc_yield_hwlock(struct mfc_dev *dev, struct mfc_ctx *curr_ctx) +static inline void __mfc_yield_hwlock(struct mfc_dev *dev, struct mfc_ctx *curr_ctx) { unsigned long flags; - if (!curr_ctx) { - mfc_err_dev("no mfc context to run\n"); - return -EINVAL; - } - - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return -EINVAL; - } - spin_lock_irqsave(&dev->hwlock.lock, flags); __mfc_release_hwlock_ctx_protected(curr_ctx); @@ -472,8 +378,6 @@ static inline int __mfc_yield_hwlock(struct mfc_dev *dev, struct mfc_ctx *curr_c /* Trigger again if other instance's work is waiting */ if (mfc_is_work_to_do(dev)) queue_work(dev->butler_wq, &dev->butler_work); - - return 0; } /* @@ -499,11 +403,6 @@ static int __mfc_try_to_get_new_ctx_protected(struct mfc_dev *dev) int index; struct mfc_ctx *new_ctx; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return -EINVAL; - } - if (dev->shutdown) { mfc_info_dev("Couldn't lock HW. Shutdown was called\n"); return -EINVAL; @@ -556,11 +455,6 @@ void mfc_try_run(struct mfc_dev *dev) int ret; unsigned long flags; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return; - } - spin_lock_irqsave(&dev->hwlock.lock, flags); __mfc_print_hwlock(dev); @@ -588,18 +482,7 @@ void mfc_try_run(struct mfc_dev *dev) */ void mfc_cleanup_work_bit_and_try_run(struct mfc_ctx *curr_ctx) { - struct mfc_dev *dev; - - if (!curr_ctx) { - mfc_err_dev("no mfc context to run\n"); - return; - } - - dev = curr_ctx->dev; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return; - } + struct mfc_dev *dev = curr_ctx->dev; mfc_clear_bit(curr_ctx->num, &dev->work_bits); @@ -824,11 +707,6 @@ int mfc_just_run(struct mfc_dev *dev, int new_ctx_index) unsigned int ret = 0; int need_cache_flush = 0; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return -EINVAL; - } - ctx = dev->ctx[new_ctx_index]; if (!ctx) { mfc_err_dev("no mfc context to run\n"); @@ -911,16 +789,6 @@ void mfc_hwlock_handler_irq(struct mfc_dev *dev, struct mfc_ctx *curr_ctx, unsigned long flags; int ret; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return; - } - - if (!curr_ctx) { - mfc_err_dev("no mfc context to run\n"); - return; - } - spin_lock_irqsave(&dev->hwlock.lock, flags); __mfc_print_hwlock(dev); diff --git a/drivers/media/platform/exynos/mfc/mfc_hwlock.h b/drivers/media/platform/exynos/mfc/mfc_hwlock.h index b2c3f1dd3b90..1c88a13294e7 100644 --- a/drivers/media/platform/exynos/mfc/mfc_hwlock.h +++ b/drivers/media/platform/exynos/mfc/mfc_hwlock.h @@ -68,8 +68,8 @@ void mfc_init_hwlock(struct mfc_dev *dev); int mfc_get_hwlock_dev(struct mfc_dev *dev); int mfc_get_hwlock_ctx(struct mfc_ctx *curr_ctx); -int mfc_release_hwlock_dev(struct mfc_dev *dev); -int mfc_release_hwlock_ctx(struct mfc_ctx *curr_ctx); +void mfc_release_hwlock_dev(struct mfc_dev *dev); +void mfc_release_hwlock_ctx(struct mfc_ctx *curr_ctx); void mfc_cache_flush(struct mfc_dev *dev, int is_drm); diff --git a/drivers/media/platform/exynos/mfc/mfc_isr.c b/drivers/media/platform/exynos/mfc/mfc_isr.c index afd32f3f1d61..c9c5646d8358 100644 --- a/drivers/media/platform/exynos/mfc/mfc_isr.c +++ b/drivers/media/platform/exynos/mfc/mfc_isr.c @@ -726,7 +726,7 @@ leave_handle_frame: static void __mfc_handle_stream_copy_timestamp(struct mfc_ctx *ctx, struct mfc_buf *src_mb) { - struct mfc_dev *dev; + struct mfc_dev *dev = ctx->dev; struct mfc_enc *enc = ctx->enc_priv; struct mfc_enc_params *p = &enc->params; struct mfc_buf *dst_mb; @@ -734,17 +734,6 @@ static void __mfc_handle_stream_copy_timestamp(struct mfc_ctx *ctx, struct mfc_b u64 start_timestamp; u64 new_timestamp; - if (!ctx) { - mfc_err_dev("[BUFCON][TS] no mfc context to run\n"); - return; - } - - dev = ctx->dev; - if (!dev) { - mfc_err_dev("[BUFCON][TS] no device to run\n"); - return; - } - start_timestamp = src_mb->vb.vb2_buf.timestamp; interval = NSEC_PER_SEC / p->rc_framerate; if (debug_ts == 1) diff --git a/drivers/media/platform/exynos/mfc/mfc_nal_q.c b/drivers/media/platform/exynos/mfc/mfc_nal_q.c index a4ed5fec3d8a..e742a781448f 100644 --- a/drivers/media/platform/exynos/mfc/mfc_nal_q.c +++ b/drivers/media/platform/exynos/mfc/mfc_nal_q.c @@ -35,11 +35,6 @@ int mfc_nal_q_check_enable(struct mfc_dev *dev) mfc_debug_enter(); - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return -EINVAL; - } - if (nal_q_disable) return 0; @@ -193,11 +188,6 @@ static int __mfc_nal_q_find_ctx(struct mfc_dev *dev, EncoderOutputStr *pOutputSt { int i; - if (!dev) { - mfc_err_dev("[NALQ] no mfc device to run\n"); - return -EINVAL; - } - for(i = 0; i < MFC_NUM_CONTEXTS; i++) { if (dev->ctx[i] && dev->ctx[i]->inst_no == pOutputStr->InstanceId) return i; @@ -212,11 +202,6 @@ static nal_queue_in_handle* __mfc_nal_q_create_in_q(struct mfc_dev *dev, mfc_debug_enter(); - if (!dev) { - mfc_err_dev("[NALQ] no mfc device to run\n"); - return NULL; - } - nal_q_in_handle = kzalloc(sizeof(*nal_q_in_handle), GFP_KERNEL); if (!nal_q_in_handle) { mfc_err_dev("[NALQ] Failed to get memory for nal_queue_in_handle\n"); @@ -245,11 +230,6 @@ static nal_queue_out_handle* __mfc_nal_q_create_out_q(struct mfc_dev *dev, mfc_debug_enter(); - if (!dev) { - mfc_err_dev("[NALQ] no mfc device to run\n"); - return NULL; - } - nal_q_out_handle = kzalloc(sizeof(*nal_q_out_handle), GFP_KERNEL); if (!nal_q_out_handle) { mfc_err_dev("[NALQ] failed to get memory for nal_queue_out_handle\n"); @@ -314,11 +294,6 @@ nal_queue_handle *mfc_nal_q_create(struct mfc_dev *dev) mfc_debug_enter(); - if (!dev) { - mfc_err_dev("[NALQ] no mfc device to run\n"); - return NULL; - } - nal_q_handle = kzalloc(sizeof(*nal_q_handle), GFP_KERNEL); if (!nal_q_handle) { mfc_err_dev("[NALQ] no nal_q_handle\n"); @@ -357,11 +332,6 @@ int mfc_nal_q_destroy(struct mfc_dev *dev, nal_queue_handle *nal_q_handle) mfc_debug_enter(); - if (!dev) { - mfc_err_dev("[NALQ] no mfc device to run\n"); - return -EINVAL; - } - if (!nal_q_handle) { mfc_err_dev("[NALQ] there isn't nal_q_handle\n"); return -EINVAL; @@ -391,11 +361,6 @@ void mfc_nal_q_init(struct mfc_dev *dev, nal_queue_handle *nal_q_handle) { mfc_debug_enter(); - if (!dev) { - mfc_err_dev("[NALQ] no mfc device to run\n"); - return; - } - if (!nal_q_handle) { mfc_err_dev("[NALQ] There is no nal_q_handle\n"); return; @@ -434,11 +399,6 @@ void mfc_nal_q_start(struct mfc_dev *dev, nal_queue_handle *nal_q_handle) mfc_debug_enter(); - if (!dev) { - mfc_err_dev("[NALQ] no mfc device to run\n"); - return; - } - if (!nal_q_handle) { mfc_err_dev("[NALQ] There is no nal_q_handle\n"); return; @@ -483,11 +443,6 @@ void mfc_nal_q_stop(struct mfc_dev *dev, nal_queue_handle *nal_q_handle) { mfc_debug_enter(); - if (!dev) { - mfc_err_dev("[NALQ] no mfc device to run\n"); - return; - } - if (!nal_q_handle) { mfc_err_dev("[NALQ] There is no nal_q_handle\n"); return; @@ -517,11 +472,6 @@ void mfc_nal_q_stop_if_started(struct mfc_dev *dev) mfc_debug_enter(); - if (!dev) { - mfc_err_dev("[NALQ] no mfc device to run\n"); - return; - } - nal_q_handle = dev->nal_q_handle; if (!nal_q_handle) { mfc_err_dev("[NALQ] There is no nal_q_handle\n"); @@ -556,11 +506,6 @@ void mfc_nal_q_cleanup_queue(struct mfc_dev *dev) mfc_debug_enter(); - if (!dev) { - mfc_err_dev("[NALQ] no mfc device to run\n"); - return; - } - for(i = 0; i < MFC_NUM_CONTEXTS; i++) { ctx = dev->ctx[i]; if (ctx) { @@ -607,7 +552,7 @@ static void __mfc_nal_q_set_slice_mode(struct mfc_ctx *ctx, EncoderInputStr *pIn static int __mfc_nal_q_run_in_buf_enc(struct mfc_ctx *ctx, EncoderInputStr *pInStr) { - struct mfc_dev *dev; + struct mfc_dev *dev = ctx->dev; struct mfc_buf *src_mb, *dst_mb; struct mfc_raw_info *raw = NULL; dma_addr_t src_addr[3] = {0, 0, 0}; @@ -616,16 +561,6 @@ static int __mfc_nal_q_run_in_buf_enc(struct mfc_ctx *ctx, EncoderInputStr *pInS mfc_debug_enter(); - if (!ctx) { - mfc_err_dev("[NALQ] no mfc context to run\n"); - return -EINVAL; - } - dev = ctx->dev; - if (!dev) { - mfc_err_dev("[NALQ] no mfc device to run\n"); - return -EINVAL; - } - pInStr->StartCode = 0xBBBBBBBB; pInStr->CommandId = mfc_get_nal_q_input_count(); pInStr->InstanceId = ctx->inst_no; @@ -732,9 +667,9 @@ static int __mfc_nal_q_run_in_buf_enc(struct mfc_ctx *ctx, EncoderInputStr *pInS static int __mfc_nal_q_run_in_buf_dec(struct mfc_ctx *ctx, DecoderInputStr *pInStr) { - struct mfc_dev *dev; + struct mfc_dev *dev = ctx->dev; struct mfc_buf *src_mb, *dst_mb; - struct mfc_dec *dec; + struct mfc_dec *dec = ctx->dec_priv; struct mfc_raw_info *raw = &ctx->raw_buf; dma_addr_t buf_addr; unsigned int strm_size; @@ -744,21 +679,6 @@ static int __mfc_nal_q_run_in_buf_dec(struct mfc_ctx *ctx, DecoderInputStr *pInS mfc_debug_enter(); - if (!ctx) { - mfc_err_dev("[NALQ] no mfc context to run\n"); - return -EINVAL; - } - dev = ctx->dev; - if (!dev) { - mfc_err_dev("[NALQ] no mfc device to run\n"); - return -EINVAL; - } - dec = ctx->dec_priv; - if (!dec) { - mfc_err_dev("[NALQ] no mfc decoder to run\n"); - return -EINVAL; - } - if (mfc_is_queue_count_same(&ctx->buf_queue_lock, &ctx->dst_buf_queue, 0) && mfc_is_queue_count_smaller(&ctx->buf_queue_lock, &ctx->ref_buf_queue, (ctx->dpb_count + 5))) { @@ -875,7 +795,7 @@ static void __mfc_nal_q_get_enc_frame_buffer(struct mfc_ctx *ctx, static void __mfc_nal_q_handle_stream_copy_timestamp(struct mfc_ctx *ctx, struct mfc_buf *src_mb) { - struct mfc_dev *dev; + struct mfc_dev *dev = ctx->dev; struct mfc_enc *enc = ctx->enc_priv; struct mfc_enc_params *p = &enc->params; struct mfc_buf *dst_mb; @@ -883,17 +803,6 @@ static void __mfc_nal_q_handle_stream_copy_timestamp(struct mfc_ctx *ctx, struct u64 start_timestamp; u64 new_timestamp; - if (!ctx) { - mfc_err_dev("[NALQ][BUFCON][TS] no mfc context to run\n"); - return; - } - - dev = ctx->dev; - if (!dev) { - mfc_err_dev("[NALQ][BUFCON][TS] no device to run\n"); - return; - } - start_timestamp = src_mb->vb.vb2_buf.timestamp; interval = NSEC_PER_SEC / p->rc_framerate; if (debug_ts == 1) @@ -1167,21 +1076,13 @@ static void __mfc_nal_q_handle_ref_frame(struct mfc_ctx *ctx, DecoderOutputStr * static void __mfc_nal_q_handle_frame_copy_timestamp(struct mfc_ctx *ctx, DecoderOutputStr *pOutStr) { - struct mfc_dec *dec; - struct mfc_dev *dev; + struct mfc_dec *dec = ctx->dec_priv; + struct mfc_dev *dev = ctx->dev; struct mfc_buf *ref_mb, *src_mb; dma_addr_t dec_y_addr; mfc_debug_enter(); - if (!ctx) { - mfc_err_dev("[NALQ][TS] no mfc context to run\n"); - return; - } - - dec = ctx->dec_priv; - dev = ctx->dev; - dec_y_addr = pOutStr->DecodedAddr[0]; /* Get the next source buffer */ @@ -1599,7 +1500,7 @@ leave_handle_frame: int __mfc_nal_q_handle_error(struct mfc_ctx *ctx, EncoderOutputStr *pOutStr, int err) { - struct mfc_dev *dev; + struct mfc_dev *dev = ctx->dev; struct mfc_dec *dec; struct mfc_enc *enc; struct mfc_buf *src_mb; @@ -1607,17 +1508,6 @@ int __mfc_nal_q_handle_error(struct mfc_ctx *ctx, EncoderOutputStr *pOutStr, int mfc_debug_enter(); - if (!ctx) { - mfc_err_dev("[NALQ] no mfc context to run\n"); - goto end; - } - - dev = ctx->dev; - if (!dev) { - mfc_err_dev("[NALQ] no mfc device to run\n"); - goto end; - } - mfc_err_ctx("[NALQ] Interrupt Error: %d\n", pOutStr->ErrorCode); dev->nal_q_handle->nal_q_exception = 1; @@ -1678,11 +1568,6 @@ int mfc_nal_q_handle_out_buf(struct mfc_dev *dev, EncoderOutputStr *pOutStr) mfc_debug_enter(); - if (!dev) { - mfc_err_dev("[NALQ] no mfc device to run\n"); - return -EINVAL; - } - ctx_num = dev->nal_q_handle->nal_q_out_handle->nal_q_ctx; if (ctx_num < 0) { mfc_err_dev("[NALQ] Can't find ctx in nal q\n"); diff --git a/drivers/media/platform/exynos/mfc/mfc_otf.c b/drivers/media/platform/exynos/mfc/mfc_otf.c index f35524335b05..033dc38fb253 100644 --- a/drivers/media/platform/exynos/mfc/mfc_otf.c +++ b/drivers/media/platform/exynos/mfc/mfc_otf.c @@ -262,22 +262,9 @@ static void __mfc_otf_destroy_handle(struct mfc_ctx *ctx) int mfc_otf_create(struct mfc_ctx *ctx) { - struct mfc_dev *dev; + struct mfc_dev *dev = ctx->dev; int i; - mfc_debug_enter(); - - if (!ctx) { - mfc_err_dev("[OTF] no mfc context to run\n"); - return -EINVAL; - } - - dev = ctx->dev; - if (!dev) { - mfc_err_dev("[OTF] no mfc device to run\n"); - return -EINVAL; - } - for (i = 0; i < MFC_NUM_CONTEXTS; i++) { if (dev->ctx[i] && dev->ctx[i]->otf_handle) { mfc_err_dev("[OTF] otf_handle is already created, ctx: %d\n", i); diff --git a/drivers/media/platform/exynos/mfc/mfc_reg_api.c b/drivers/media/platform/exynos/mfc/mfc_reg_api.c index 469a7fc39221..1b7aa749ecd9 100644 --- a/drivers/media/platform/exynos/mfc/mfc_reg_api.c +++ b/drivers/media/platform/exynos/mfc/mfc_reg_api.c @@ -82,8 +82,8 @@ void mfc_otf_set_hwfc_index(struct mfc_ctx *ctx, int job_id) /* Set decoding frame buffer */ int mfc_set_dec_codec_buffers(struct mfc_ctx *ctx) { - struct mfc_dev *dev; - struct mfc_dec *dec; + struct mfc_dev *dev = ctx->dev; + struct mfc_dec *dec = ctx->dec_priv; unsigned int i; size_t frame_size_mv; dma_addr_t buf_addr; @@ -92,23 +92,6 @@ int mfc_set_dec_codec_buffers(struct mfc_ctx *ctx) struct mfc_raw_info *raw; unsigned int reg = 0; - if (!ctx) { - mfc_err_dev("no mfc context to run\n"); - return -EINVAL; - } - - dev = ctx->dev; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return -EINVAL; - } - - dec = ctx->dec_priv; - if (!dec) { - mfc_err_dev("no mfc decoder to run\n"); - return -EINVAL; - } - raw = &ctx->raw_buf; buf_addr = ctx->codec_buf.daddr; buf_size = ctx->codec_buf.size; @@ -267,27 +250,13 @@ int mfc_set_enc_codec_buffers(struct mfc_ctx *ctx) int mfc_set_dec_stream_buffer(struct mfc_ctx *ctx, struct mfc_buf *mfc_buf, unsigned int start_num_byte, unsigned int strm_size) { - struct mfc_dev *dev; - struct mfc_dec *dec; + struct mfc_dev *dev = ctx->dev; + struct mfc_dec *dec = ctx->dec_priv; unsigned int cpb_buf_size; dma_addr_t addr; int index = -1; mfc_debug_enter(); - if (!ctx) { - mfc_err_dev("no mfc context to run\n"); - return -EINVAL; - } - dev = ctx->dev; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return -EINVAL; - } - dec = ctx->dec_priv; - if (!dec) { - mfc_err_dev("no mfc decoder to run\n"); - return -EINVAL; - } cpb_buf_size = ALIGN(dec->src_buf_size, STREAM_BUF_ALIGN); diff --git a/drivers/media/platform/exynos/mfc/mfc_sync.c b/drivers/media/platform/exynos/mfc/mfc_sync.c index bbe0513d56ae..406e62cbf89b 100644 --- a/drivers/media/platform/exynos/mfc/mfc_sync.c +++ b/drivers/media/platform/exynos/mfc/mfc_sync.c @@ -132,11 +132,6 @@ wait_done: void mfc_wake_up_dev(struct mfc_dev *dev, unsigned int reason, unsigned int err) { - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return; - } - dev->int_condition = 1; dev->int_reason = reason; dev->int_err = err; @@ -147,11 +142,6 @@ void mfc_wake_up_dev(struct mfc_dev *dev, unsigned int reason, void mfc_wake_up_ctx(struct mfc_ctx *ctx, unsigned int reason, unsigned int err) { - if (!ctx) { - mfc_err_dev("no mfc context to run\n"); - return; - } - ctx->int_condition = 1; ctx->int_reason = reason; ctx->int_err = err; @@ -165,11 +155,6 @@ int mfc_get_new_ctx(struct mfc_dev *dev) int cnt = 0; int i; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return -EINVAL; - } - spin_lock_irqsave(&dev->work_bits.lock, wflags); mfc_debug(2, "Previous context: %d (bits %08lx)\n", dev->curr_ctx, diff --git a/drivers/media/platform/exynos/mfc/mfc_utils.c b/drivers/media/platform/exynos/mfc/mfc_utils.c index 838e322e2310..b20107f3c4a0 100644 --- a/drivers/media/platform/exynos/mfc/mfc_utils.c +++ b/drivers/media/platform/exynos/mfc/mfc_utils.c @@ -192,23 +192,15 @@ static void __mfc_set_linear_stride_size(struct mfc_ctx *ctx, void mfc_dec_calc_dpb_size(struct mfc_ctx *ctx) { - struct mfc_dev *dev; - struct mfc_dec *dec; + struct mfc_dev *dev = ctx->dev; + struct mfc_dec *dec = ctx->dec_priv; struct mfc_raw_info *raw; int i; int extra = MFC_LINEAR_BUF_SIZE; - if (!ctx) { - mfc_err_dev("no mfc context to run\n"); - return; - } - - dev = ctx->dev; raw = &ctx->raw_buf; raw->total_plane_size = 0; - dec = ctx->dec_priv; - for (i = 0; i < raw->num_planes; i++) { raw->plane_size[i] = 0; raw->plane_size_2bits[i] = 0; @@ -314,17 +306,11 @@ void mfc_dec_calc_dpb_size(struct mfc_ctx *ctx) void mfc_enc_calc_src_size(struct mfc_ctx *ctx) { - struct mfc_dev *dev; + struct mfc_dev *dev = ctx->dev; struct mfc_raw_info *raw; unsigned int mb_width, mb_height, default_size; int i, extra; - if (!ctx) { - mfc_err_dev("no mfc context to run\n"); - return; - } - - dev = ctx->dev; raw = &ctx->raw_buf; raw->total_plane_size = 0; mb_width = WIDTH_MB(ctx->img_width); @@ -490,11 +476,6 @@ void mfc_watchdog_tick(unsigned long arg) { struct mfc_dev *dev = (struct mfc_dev *)arg; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return; - } - mfc_debug(5, "watchdog is ticking!\n"); if (atomic_read(&dev->watchdog_tick_running)) -- 2.20.1