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.
Unified · Split
| @@ -177,21 +177,6 @@ unlock: · 176 unmodified lines | ||
| 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); |
| @@ -705,6 +690,7 @@ irq_cleanup_hw: · 507 unmodified lines | ||
| 705 | 690 | /* Open an MFC node */ |
| 706 | 691 | static int s5p_mfc_open(struct file *file) |
| 707 | 692 | { |
| 693 | + struct video_device *vdev = video_devdata(file); | |
| 708 | 694 | struct s5p_mfc_dev *dev = video_drvdata(file); |
| 709 | 695 | struct s5p_mfc_ctx *ctx = NULL; |
| 710 | 696 | struct vb2_queue *q; |
| @@ -742,7 +728,7 @@ static int s5p_mfc_open(struct file *file) · 31 unmodified lines | ||
| 742 | 728 | /* Mark context as idle */ |
| 743 | 729 | clear_work_bit_irqsave(ctx); |
| 744 | 730 | dev->ctx[ctx->num] = ctx; |
| 745 | − if (s5p_mfc_get_node_type(file) == MFCNODE_DECODER) { | |
| 731 | + if (vdev == dev->vfd_dec) { | |
| 746 | 732 | ctx->type = MFCINST_DECODER; |
| 747 | 733 | ctx->c_ops = get_dec_codec_ops(); |
| 748 | 734 | s5p_mfc_dec_init(ctx); |
| @@ -752,7 +738,7 @@ static int s5p_mfc_open(struct file *file) · 3 unmodified lines | ||
| 752 | 738 | mfc_err("Failed to setup mfc controls\n"); |
| 753 | 739 | goto err_ctrls_setup; |
| 754 | 740 | } |
| 755 | − } else if (s5p_mfc_get_node_type(file) == MFCNODE_ENCODER) { | |
| 741 | + } else if (vdev == dev->vfd_enc) { | |
| 756 | 742 | ctx->type = MFCINST_ENCODER; |
| 757 | 743 | ctx->c_ops = get_enc_codec_ops(); |
| 758 | 744 | /* only for encoder */ |
| @@ -797,10 +783,10 @@ static int s5p_mfc_open(struct file *file) · 38 unmodified lines | ||
| 797 | 783 | q = &ctx->vq_dst; |
| 798 | 784 | q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
| 799 | 785 | q->drv_priv = &ctx->fh; |
| 800 | − if (s5p_mfc_get_node_type(file) == MFCNODE_DECODER) { | |
| 786 | + if (vdev == dev->vfd_dec) { | |
| 801 | 787 | q->io_modes = VB2_MMAP; |
| 802 | 788 | q->ops = get_dec_queue_ops(); |
| 803 | − } else if (s5p_mfc_get_node_type(file) == MFCNODE_ENCODER) { | |
| 789 | + } else if (vdev == dev->vfd_enc) { | |
| 804 | 790 | q->io_modes = VB2_MMAP | VB2_USERPTR; |
| 805 | 791 | q->ops = get_enc_queue_ops(); |
| 806 | 792 | } else { |
| @@ -819,10 +805,10 @@ static int s5p_mfc_open(struct file *file) · 12 unmodified lines | ||
| 819 | 805 | q->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |
| 820 | 806 | q->io_modes = VB2_MMAP; |
| 821 | 807 | q->drv_priv = &ctx->fh; |
| 822 | − if (s5p_mfc_get_node_type(file) == MFCNODE_DECODER) { | |
| 808 | + if (vdev == dev->vfd_dec) { | |
| 823 | 809 | q->io_modes = VB2_MMAP; |
| 824 | 810 | q->ops = get_dec_queue_ops(); |
| 825 | − } else if (s5p_mfc_get_node_type(file) == MFCNODE_ENCODER) { | |
| 811 | + } else if (vdev == dev->vfd_enc) { | |
| 826 | 812 | q->io_modes = VB2_MMAP | VB2_USERPTR; |
| 827 | 813 | q->ops = get_enc_queue_ops(); |
| 828 | 814 | } else { |
| @@ -114,15 +114,6 @@ enum s5p_mfc_fmt_type { · 113 unmodified lines | ||
| 114 | 114 | MFC_FMT_RAW, |
| 115 | 115 | }; |
| 116 | 116 | |
| 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 | 117 | /** |
| 127 | 118 | * enum s5p_mfc_inst_type - The type of an MFC instance. |
| 128 | 119 | */ |