Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] media: s5p_mfc: remove s5p_mfc_get_node_type() function

s5p_mfc_get_node_type() relies on get_index() helper function, which in
turn relies on video_device index numbers assigned on driver
registration. All this code is not really needed, because there is
already access to respective video_device structures via common
s5p_mfc_dev structure. This fixes the issues introduced by patch
1056e4388b0454917a512618c8416a98628fc9ce ("v4l2-dev: Fix race condition
on __video_register_device"), which has been merged in v3.12-rc1.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: stable@vger.kernel.org
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

authored by

Marek Szyprowski and committed by
Mauro Carvalho Chehab
b80cb8dc 4773ab99

+7 -30
+7 -21
drivers/media/platform/s5p-mfc/s5p_mfc.c
··· 177 177 mutex_unlock(&dev->mfc_mutex); 178 178 } 179 179 180 - static enum s5p_mfc_node_type s5p_mfc_get_node_type(struct file *file) 181 - { 182 - struct video_device *vdev = video_devdata(file); 183 - 184 - if (!vdev) { 185 - mfc_err("failed to get video_device"); 186 - return MFCNODE_INVALID; 187 - } 188 - if (vdev->index == 0) 189 - return MFCNODE_DECODER; 190 - else if (vdev->index == 1) 191 - return MFCNODE_ENCODER; 192 - return MFCNODE_INVALID; 193 - } 194 - 195 180 static void s5p_mfc_clear_int_flags(struct s5p_mfc_dev *dev) 196 181 { 197 182 mfc_write(dev, 0, S5P_FIMV_RISC_HOST_INT); ··· 690 705 /* Open an MFC node */ 691 706 static int s5p_mfc_open(struct file *file) 692 707 { 708 + struct video_device *vdev = video_devdata(file); 693 709 struct s5p_mfc_dev *dev = video_drvdata(file); 694 710 struct s5p_mfc_ctx *ctx = NULL; 695 711 struct vb2_queue *q; ··· 728 742 /* Mark context as idle */ 729 743 clear_work_bit_irqsave(ctx); 730 744 dev->ctx[ctx->num] = ctx; 731 - if (s5p_mfc_get_node_type(file) == MFCNODE_DECODER) { 745 + if (vdev == dev->vfd_dec) { 732 746 ctx->type = MFCINST_DECODER; 733 747 ctx->c_ops = get_dec_codec_ops(); 734 748 s5p_mfc_dec_init(ctx); ··· 738 752 mfc_err("Failed to setup mfc controls\n"); 739 753 goto err_ctrls_setup; 740 754 } 741 - } else if (s5p_mfc_get_node_type(file) == MFCNODE_ENCODER) { 755 + } else if (vdev == dev->vfd_enc) { 742 756 ctx->type = MFCINST_ENCODER; 743 757 ctx->c_ops = get_enc_codec_ops(); 744 758 /* only for encoder */ ··· 783 797 q = &ctx->vq_dst; 784 798 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; 785 799 q->drv_priv = &ctx->fh; 786 - if (s5p_mfc_get_node_type(file) == MFCNODE_DECODER) { 800 + if (vdev == dev->vfd_dec) { 787 801 q->io_modes = VB2_MMAP; 788 802 q->ops = get_dec_queue_ops(); 789 - } else if (s5p_mfc_get_node_type(file) == MFCNODE_ENCODER) { 803 + } else if (vdev == dev->vfd_enc) { 790 804 q->io_modes = VB2_MMAP | VB2_USERPTR; 791 805 q->ops = get_enc_queue_ops(); 792 806 } else { ··· 805 819 q->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; 806 820 q->io_modes = VB2_MMAP; 807 821 q->drv_priv = &ctx->fh; 808 - if (s5p_mfc_get_node_type(file) == MFCNODE_DECODER) { 822 + if (vdev == dev->vfd_dec) { 809 823 q->io_modes = VB2_MMAP; 810 824 q->ops = get_dec_queue_ops(); 811 - } else if (s5p_mfc_get_node_type(file) == MFCNODE_ENCODER) { 825 + } else if (vdev == dev->vfd_enc) { 812 826 q->io_modes = VB2_MMAP | VB2_USERPTR; 813 827 q->ops = get_enc_queue_ops(); 814 828 } else {
-9
drivers/media/platform/s5p-mfc/s5p_mfc_common.h
··· 115 115 }; 116 116 117 117 /** 118 - * enum s5p_mfc_node_type - The type of an MFC device node. 119 - */ 120 - enum s5p_mfc_node_type { 121 - MFCNODE_INVALID = -1, 122 - MFCNODE_DECODER = 0, 123 - MFCNODE_ENCODER = 1, 124 - }; 125 - 126 - /** 127 118 * enum s5p_mfc_inst_type - The type of an MFC instance. 128 119 */ 129 120 enum s5p_mfc_inst_type {